From 39035fbfc5f6dfa66c9ba14f61a8d1c751d847c0 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 16 Apr 2023 08:51:22 +0300 Subject: [PATCH] Avoid crashes in 'describe-keymap' due to shadowing * src/keymap.c (describe_vector): Handle shadowing by something other than a symbol. (Bug#62867) --- src/keymap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/keymap.c b/src/keymap.c index efac410d317..7f5777c9251 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -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); } } -- 2.39.5