]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid crashes in 'describe-keymap' due to shadowing
authorEli Zaretskii <eliz@gnu.org>
Sun, 16 Apr 2023 05:51:22 +0000 (08:51 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 16 Apr 2023 05:51:22 +0000 (08:51 +0300)
* src/keymap.c (describe_vector): Handle shadowing by something
other than a symbol.  (Bug#62867)

src/keymap.c

index efac410d317d768adc5c1c9a032e5431ca7430c6..7f5777c92513e4c6dc40f20a15f1071f12f5b380 100644 (file)
@@ -3308,13 +3308,18 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
       if (this_shadowed)
        {
          SET_PT (PT - 1);
-         static char const fmt[] = "  (currently shadowed by `%s')";
-         USE_SAFE_ALLOCA;
-         char *buffer = SAFE_ALLOCA (sizeof fmt +
-                                     SBYTES (SYMBOL_NAME (shadowed_by)));
-         esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by)));
-         insert_string (buffer);
-         SAFE_FREE();
+         if (SYMBOLP (shadowed_by))
+           {
+             static char const fmt[] = "  (currently shadowed by `%s')";
+             USE_SAFE_ALLOCA;
+             char *buffer =
+               SAFE_ALLOCA (sizeof fmt + SBYTES (SYMBOL_NAME (shadowed_by)));
+             esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by)));
+             insert_string (buffer);
+             SAFE_FREE();
+           }
+         else  /* Could be a keymap, a lambda, or a keyboard macro.  */
+           insert_string ("  (currently shadowed)");
          SET_PT (PT + 1);
        }
     }