emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-28 e170a31: Avoid signaling errors in lookup-key


From: Eli Zaretskii
Subject: emacs-28 e170a31: Avoid signaling errors in lookup-key
Date: Sun, 31 Oct 2021 10:21:12 -0400 (EDT)

branch: emacs-28
commit e170a31c57b61eb40878bf28a850b2b492947ee8
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    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.
---
 src/keymap.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/keymap.c b/src/keymap.c
index 50f896d..28ff71c 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1259,22 +1259,28 @@ recognize the default bindings, just as 
`read-key-sequence' does.  */)
       Lisp_Object new_key = make_vector (key_len, Qnil);
       for (int i = 0; i < key_len; ++i)
        {
-         Lisp_Object sym = Fsymbol_name (AREF (key, i));
-         USE_SAFE_ALLOCA;
-         unsigned char *dst = SAFE_ALLOCA (SBYTES (sym) + 1);
-         memcpy (dst, SSDATA (sym), SBYTES (sym));
-         /* We can walk the string data byte by byte, because UTF-8
-            encoding ensures that no other byte of any multibyte
-            sequence will ever include a 7-bit byte equal to an ASCII
-            single-byte character.  */
-         for (int j = 0; j < SBYTES (sym); ++j)
-           if (dst[j] >= 'A' && dst[j] <= 'Z')
-             dst[j] += 'a' - 'A';  /* Convert to lower case.  */
-         ASET (new_key, i, Fintern (make_multibyte_string ((char *) dst,
-                                                           SCHARS (sym),
-                                                           SBYTES (sym)),
-                                    Qnil));
-         SAFE_FREE ();
+         Lisp_Object item = AREF (key, i);
+         if (!SYMBOLP (item))
+           ASET (new_key, i, item);
+         else
+           {
+             Lisp_Object sym = Fsymbol_name (item);
+             USE_SAFE_ALLOCA;
+             unsigned char *dst = SAFE_ALLOCA (SBYTES (sym) + 1);
+             memcpy (dst, SSDATA (sym), SBYTES (sym));
+             /* We can walk the string data byte by byte, because
+                UTF-8 encoding ensures that no other byte of any
+                multibyte sequence will ever include a 7-bit byte
+                equal to an ASCII single-byte character.  */
+             for (int j = 0; j < SBYTES (sym); ++j)
+               if (dst[j] >= 'A' && dst[j] <= 'Z')
+                 dst[j] += 'a' - 'A';  /* Convert to lower case.  */
+             ASET (new_key, i, Fintern (make_multibyte_string ((char *) dst,
+                                                               SCHARS (sym),
+                                                               SBYTES (sym)),
+                                        Qnil));
+             SAFE_FREE ();
+           }
        }
       found = lookup_key_1 (keymap, new_key, accept_default);
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]