From: Lars Ingebrigtsen Date: Mon, 14 Oct 2019 00:52:25 +0000 (+0200) Subject: Further changes to ensure that copy-keymap doesn't segfault X-Git-Tag: emacs-27.0.90~1091 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d1963b312d021e277c12005a2b130c292623e5e7;p=emacs.git 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)) --- diff --git a/src/keymap.c b/src/keymap.c index 5aed4129bb7..0b7de3e9cc5 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -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)); + Fset_char_table_range + (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)) {