changeset 99136:cc2b9071d713

(read_char_minibuf_menu_prompt): Ensure that read_char_minibuf_menu_text is large enough to hold the menu string.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 25 Oct 2008 20:23:31 +0000
parents d5bebbe40609
children d54dee52948e
files src/keyboard.c
diffstat 1 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Sat Oct 25 20:21:19 2008 +0000
+++ b/src/keyboard.c	Sat Oct 25 20:23:31 2008 +0000
@@ -8558,7 +8558,20 @@
   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 @@
     }
   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);