From 9ad3560db6b67777bc8f9b370e053b6a19a7501f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 29 Mar 2018 09:11:22 -0400 Subject: [PATCH] * src/keyboard.c (record_char, read_key_sequence): Copy raw events --- src/keyboard.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 044e3fac693..c0c863f0d3e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3258,7 +3258,10 @@ record_char (Lisp_Object c) if (!recorded) { total_keys += total_keys < NUM_RECENT_KEYS; - ASET (recent_keys, recent_keys_index, c); + ASET (recent_keys, recent_keys_index, + /* Copy the event, in case it gets modified by side-effect + by some remapping function (bug#30955). */ + CONSP (c) ? Fcopy_sequence (c) : c); if (++recent_keys_index >= NUM_RECENT_KEYS) recent_keys_index = 0; } @@ -9296,7 +9299,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, } GROW_RAW_KEYBUF; - ASET (raw_keybuf, raw_keybuf_count, key); + ASET (raw_keybuf, raw_keybuf_count, + /* Copy the event, in case it gets modified by side-effect + by some remapping function (bug#30955). */ + CONSP (key) ? Fcopy_sequence (key) : key); raw_keybuf_count++; } @@ -9343,9 +9349,6 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, && BUFFERP (XWINDOW (window)->contents) && XBUFFER (XWINDOW (window)->contents) != current_buffer) { - GROW_RAW_KEYBUF; - ASET (raw_keybuf, raw_keybuf_count, key); - raw_keybuf_count++; keybuf[t] = key; mock_input = t + 1; -- 2.39.2