emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 658f2c4: Avoid crashes due to invalid coding-system


From: Eli Zaretskii
Subject: [Emacs-diffs] master 658f2c4: Avoid crashes due to invalid coding-system
Date: Sat, 03 Oct 2015 10:46:42 +0000

branch: master
commit 658f2c450d17357d8c09a07ca92c2ca980c3c797
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid crashes due to invalid coding-system
    
    * 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 |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index e4b255a..65aaf57 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]