From f3555fc846e536cd038f47177356a98a4ee06a20 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 21 Feb 2026 19:27:17 +0200 Subject: [PATCH] Avoid segfaults if someone sets 'composition-function-table' to nil * src/composite.c (composition_compute_stop_pos) (composition_reseat_it): Recreate 'composition-function-table' if it ever becomes garbled. (Bug#80462) --- src/composite.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/composite.c b/src/composite.c index 2eddda00b5d..e36e1670d8d 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1101,6 +1101,9 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos, /* Look for automatic compositions. */ start = charpos; + /* For the case that they set it to something weird, like nil. */ + if (!CHAR_TABLE_P (Vcomposition_function_table)) + Vcomposition_function_table = Fmake_char_table (Qnil, Qnil); if (charpos < endpos) { /* Forward search. */ @@ -1324,6 +1327,9 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, Lisp_Object lgstring = Qnil; Lisp_Object val, elt, direction = Qnil; + /* For the case that they set it to something weird, like nil. */ + if (!CHAR_TABLE_P (Vcomposition_function_table)) + Vcomposition_function_table = Fmake_char_table (Qnil, Qnil); val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch); for (EMACS_INT i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val)) continue;