aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2021-10-31 16:20:27 +0200
committerEli Zaretskii2021-10-31 16:20:27 +0200
commite170a31c57b61eb40878bf28a850b2b492947ee8 (patch)
treef25c9cbf41740cdbc5b8d55219c1bbfcc29f7709 /src
parent5e05be566b0e13ce0b4e75da663fb051039f0751 (diff)
downloademacs-e170a31c57b61eb40878bf28a850b2b492947ee8.tar.gz
emacs-e170a31c57b61eb40878bf28a850b2b492947ee8.zip
Avoid signaling errors in lookup-key
* src/keymap.c (Flookup_key): Handle KEY vectors where not all components are symbols. (Bug#51527) Do not merge to master.
Diffstat (limited to 'src')
-rw-r--r--src/keymap.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 50f896d17cf..28ff71c01da 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1259,22 +1259,28 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1259 Lisp_Object new_key = make_vector (key_len, Qnil); 1259 Lisp_Object new_key = make_vector (key_len, Qnil);
1260 for (int i = 0; i < key_len; ++i) 1260 for (int i = 0; i < key_len; ++i)
1261 { 1261 {
1262 Lisp_Object sym = Fsymbol_name (AREF (key, i)); 1262 Lisp_Object item = AREF (key, i);
1263 USE_SAFE_ALLOCA; 1263 if (!SYMBOLP (item))
1264 unsigned char *dst = SAFE_ALLOCA (SBYTES (sym) + 1); 1264 ASET (new_key, i, item);
1265 memcpy (dst, SSDATA (sym), SBYTES (sym)); 1265 else
1266 /* We can walk the string data byte by byte, because UTF-8 1266 {
1267 encoding ensures that no other byte of any multibyte 1267 Lisp_Object sym = Fsymbol_name (item);
1268 sequence will ever include a 7-bit byte equal to an ASCII 1268 USE_SAFE_ALLOCA;
1269 single-byte character. */ 1269 unsigned char *dst = SAFE_ALLOCA (SBYTES (sym) + 1);
1270 for (int j = 0; j < SBYTES (sym); ++j) 1270 memcpy (dst, SSDATA (sym), SBYTES (sym));
1271 if (dst[j] >= 'A' && dst[j] <= 'Z') 1271 /* We can walk the string data byte by byte, because
1272 dst[j] += 'a' - 'A'; /* Convert to lower case. */ 1272 UTF-8 encoding ensures that no other byte of any
1273 ASET (new_key, i, Fintern (make_multibyte_string ((char *) dst, 1273 multibyte sequence will ever include a 7-bit byte
1274 SCHARS (sym), 1274 equal to an ASCII single-byte character. */
1275 SBYTES (sym)), 1275 for (int j = 0; j < SBYTES (sym); ++j)
1276 Qnil)); 1276 if (dst[j] >= 'A' && dst[j] <= 'Z')
1277 SAFE_FREE (); 1277 dst[j] += 'a' - 'A'; /* Convert to lower case. */
1278 ASET (new_key, i, Fintern (make_multibyte_string ((char *) dst,
1279 SCHARS (sym),
1280 SBYTES (sym)),
1281 Qnil));
1282 SAFE_FREE ();
1283 }
1278 } 1284 }
1279 found = lookup_key_1 (keymap, new_key, accept_default); 1285 found = lookup_key_1 (keymap, new_key, accept_default);
1280 } 1286 }