master 13cff6ffad2: Avoid crashes due to weird 'auto-coding-regexp-alist' values
Eli Zaretskii <[email protected]> Sat, 1 Aug 2026 05:40:20 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit 13cff6ffad2d3117a75ac7e47586f5854dfe2a92 Author: Eli Zaretskii <[email protected]> Commit: Eli Zaretskii <[email protected]> Avoid crashes due to weird 'auto-coding-regexp-alist' values * src/chartab.c (uniprop_table): Bind 'coding-system-for-read' to 'utf-8-emacs-unix' for inserting the contents of the uni-*.el files. This avoids crashes if the 'coding:' cookies in these files are overridden by some means. (Bug#81445) --- src/chartab.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/chartab.c b/src/chartab.c index 758aec36929..ce3171b00bf 100644 --- a/src/chartab.c +++ b/src/chartab.c @@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include "lisp.h" #include "character.h" #include "charset.h" +#include "coding.h" /* 64/16/32/128 */ @@ -1271,7 +1272,17 @@ uniprop_table (Lisp_Object prop) if (STRINGP (table)) { AUTO_STRING (intl, "international/"); + /* The uni-*.el files _must_ be read using utf-8-emacs-unix, or + else Emacs might crash. We bind coding-system-for-read below + to protect against some Lisp which overrides the coding: + cookies in the uni-*.el files by, for example, binding + auto-coding-regexp-alist to some strange value. */ + specpdl_ref count = SPECPDL_INDEX (); + Lisp_Object coding = coding_inherit_eol_type (Qutf_8_emacs, Qunix); + specbind (Qcoding_system_for_read, coding); result = save_match_data_load (concat2 (intl, table), Qt, Qt, Qt, Qt); + unbind_to (count, Qnil); + if (NILP (result)) return Qnil; table = XCDR (val); @@ -1376,4 +1387,5 @@ syms_of_chartab (void) doc: /* Alist of character property name vs char-table containing property values. Internal use only. */); Vchar_code_property_alist = Qnil; + DEFSYM (Qcoding_system_for_read, "coding-system-for-read"); }