Commit d1963b31 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Further changes to ensure that copy-keymap doesn't segfault

* src/keymap.c (copy_keymap_1, copy_keymap_set_char_table): Ensure
we don't recurse infinitely when using non-sparse keymaps, too.

This change makes this form not segfault:

(let ((map (make-keymap)))
  (define-key map " " map)
  (copy-keymap map))
parent ea7610f1
Pipeline #3622 passed with stage
in 55 minutes and 43 seconds
......@@ -975,10 +975,12 @@ copy_keymap_item (Lisp_Object elt, int depth)
static void
copy_keymap_set_char_table (Lisp_Object chartable, Lisp_Object idx,
copy_keymap_set_char_table (Lisp_Object chartable_and_depth, Lisp_Object idx,
Lisp_Object elt)
Fset_char_table_range (chartable, idx, copy_keymap_item (elt, 0));
(XCAR (chartable_and_depth), idx,
copy_keymap_item (elt, XFIXNUM (XCDR (chartable_and_depth))));
static Lisp_Object
......@@ -999,7 +1001,8 @@ copy_keymap_1 (Lisp_Object keymap, int depth)
if (CHAR_TABLE_P (elt))
elt = Fcopy_sequence (elt);
map_char_table (copy_keymap_set_char_table, Qnil, elt, elt);
map_char_table (copy_keymap_set_char_table, Qnil, elt,
Fcons (elt, make_fixnum (depth + 1)));
else if (VECTORP (elt))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment