From: Chong Yidong Date: Sat, 25 Oct 2008 20:23:31 +0000 (+0000) Subject: (read_char_minibuf_menu_prompt): Ensure that X-Git-Tag: emacs-pretest-23.0.90~2182 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f6bb48830621e249f46e35d930f77900cb9e3068;p=emacs.git (read_char_minibuf_menu_prompt): Ensure that read_char_minibuf_menu_text is large enough to hold the menu string. --- diff --git a/src/keyboard.c b/src/keyboard.c index ec1b117a13a..b6834e97a8f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -8558,7 +8558,20 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) if (! menu_prompting) return Qnil; + /* Get the menu name from the first map that has one (a prompt string). */ + for (mapno = 0; mapno < nmaps; mapno++) + { + name = Fkeymap_prompt (maps[mapno]); + if (!NILP (name)) + break; + } + + /* If we don't have any menus, just read a character normally. */ + if (!STRINGP (name)) + return Qnil; + /* Make sure we have a big enough buffer for the menu text. */ + width = max (width, SBYTES (name)); if (read_char_minibuf_menu_text == 0) { read_char_minibuf_menu_width = width + 4; @@ -8572,18 +8585,6 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) } menu = read_char_minibuf_menu_text; - /* Get the menu name from the first map that has one (a prompt string). */ - for (mapno = 0; mapno < nmaps; mapno++) - { - name = Fkeymap_prompt (maps[mapno]); - if (!NILP (name)) - break; - } - - /* If we don't have any menus, just read a character normally. */ - if (!STRINGP (name)) - return Qnil; - /* Prompt string always starts with map's prompt, and a space. */ strcpy (menu, SDATA (name)); nlength = SBYTES (name);