]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid crashes due to invalid coding-system
authorEli Zaretskii <eliz@gnu.org>
Sat, 3 Oct 2015 10:44:44 +0000 (13:44 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 3 Oct 2015 10:44:44 +0000 (13:44 +0300)
* src/fileio.c (choose_write_coding_system)
(Finsert_file_contents): Check validity of coding-system-for-write
and coding-system-for-read bound by the caller.  (Bug#21602)

src/fileio.c

index e4b255a53ac67ec2da728445d33db8d9abb11b22..65aaf572fd76e7fa17d89d1d2b481ce9064e71b4 100644 (file)
@@ -3470,7 +3470,10 @@ by calling `format-decode', which see.  */)
       mtime = time_error_value (save_errno);
       st.st_size = -1;
       if (!NILP (Vcoding_system_for_read))
-       Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
+       {
+         CHECK_CODING_SYSTEM (Vcoding_system_for_read);
+         Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
+       }
       goto notfound;
     }
 
@@ -4526,6 +4529,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   else if (!NILP (Vcoding_system_for_write))
     {
       val = Vcoding_system_for_write;
+      CHECK_CODING_SYSTEM (val);
       if (coding_system_require_warning
          && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
        /* Confirm that VAL can surely encode the current region.  */
@@ -4574,6 +4578,9 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
          using_default_coding = 1;
        }
 
+      if (!NILP (val))
+       CHECK_CODING_SYSTEM (val);
+
       if (! NILP (val) && ! force_raw_text)
        {
          Lisp_Object spec, attrs;