summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-10-03 14:49:16 +0300
committerEli Zaretskii <eliz@gnu.org>2015-10-03 14:49:16 +0300
commit265d525a5ef9f59a6c26d40cd560ae43c3ae1d2c (patch)
tree437fe19f627c509a4d011c004f79c1972fe1eb11 /src
parent658f2c450d17357d8c09a07ca92c2ca980c3c797 (diff)
downloademacs-265d525a5ef9f59a6c26d40cd560ae43c3ae1d2c.tar.gz
emacs-265d525a5ef9f59a6c26d40cd560ae43c3ae1d2c.tar.bz2
emacs-265d525a5ef9f59a6c26d40cd560ae43c3ae1d2c.zip
More validatation of coding system in 'write-region'
* src/coding.c (choose_write_coding_system): More validation of coding-system from various sources. Suggested by Andreas Schwab <schwab@linux-m68k.org>. (Bug#21602)
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 65aaf572fd7..15bebdf09fa 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4593,17 +4593,26 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
if (!force_raw_text
&& !NILP (Ffboundp (Vselect_safe_coding_system_function)))
- /* Confirm that VAL can surely encode the current region. */
- val = call5 (Vselect_safe_coding_system_function,
- start, end, val, Qnil, filename);
+ {
+ /* Confirm that VAL can surely encode the current region. */
+ val = call5 (Vselect_safe_coding_system_function,
+ start, end, val, Qnil, filename);
+ CHECK_CODING_SYSTEM (val);
+ }
/* If the decided coding-system doesn't specify end-of-line
format, we use that of
`default-buffer-file-coding-system'. */
- if (! using_default_coding
- && ! NILP (BVAR (&buffer_defaults, buffer_file_coding_system)))
- val = (coding_inherit_eol_type
- (val, BVAR (&buffer_defaults, buffer_file_coding_system)));
+ if (! using_default_coding)
+ {
+ Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system);
+
+ if (! NILP (dflt))
+ {
+ CHECK_CODING_SYSTEM (dflt);
+ val = (coding_inherit_eol_type (val, dflt));
+ }
+ }
/* If we decide not to encode text, use `raw-text' or one of its
subsidiaries. */