summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-10-03 13:44:44 +0300
committerEli Zaretskii <eliz@gnu.org>2015-10-03 13:44:44 +0300
commit658f2c450d17357d8c09a07ca92c2ca980c3c797 (patch)
tree398db0e54815fa452a3605d0c30bd7778235359b /src/fileio.c
parent40892b46f8219e4c7795038f91878f85eaeb7bc5 (diff)
downloademacs-658f2c450d17357d8c09a07ca92c2ca980c3c797.tar.gz
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)
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index e4b255a53ac..65aaf572fd7 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;