From: Paul Eggert Date: Thu, 12 May 2011 16:16:40 +0000 (-0700) Subject: * xmenu.c (set_frame_menubar): Use int, not EMACS_UINT, for indexes X-Git-Tag: emacs-pretest-24.0.90~104^2~618^2~239^2~23^2~13 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3e26f69c4f5f7fe38081f0889186d6a9260c85e0;p=emacs.git * xmenu.c (set_frame_menubar): Use int, not EMACS_UINT, for indexes that always fit in int. Use a sentinel instead of a counter, to avoid a temp and to allay GCC's concerns about possible int overflow. --- diff --git a/src/ChangeLog b/src/ChangeLog index 913dcc05a10..3bdf5129da9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-05-12 Paul Eggert + * xmenu.c (set_frame_menubar): Use int, not EMACS_UINT, for indexes + that always fit in int. Use a sentinel instead of a counter, to + avoid a temp and to allay GCC's concerns about possible int overflow. + * menu.c (grow_menu_items): Check for int overflow. * xmenu.c (set_frame_menubar): Don't mishandle vectors with no nils. diff --git a/src/xmenu.c b/src/xmenu.c index 898aade06c2..ccb60d2dcbb 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -922,7 +922,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) #endif Lisp_Object items; widget_value *wv, *first_wv, *prev_wv = 0; - EMACS_UINT i, last_i; + int i; int *submenu_start, *submenu_end; int *submenu_top_level_items, *submenu_n_panes; @@ -966,7 +966,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) Lisp_Object *previous_items = (Lisp_Object *) alloca (previous_menu_items_used * sizeof (Lisp_Object)); - EMACS_UINT subitems; + int subitems; /* If we are making a new widget, its contents are empty, do always reinitialize them. */ @@ -1012,7 +1012,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) menu_items = f->menu_bar_vector; menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; subitems = ASIZE (items) / 4; - submenu_start = (int *) alloca (subitems * sizeof (int)); + submenu_start = (int *) alloca ((subitems + 1) * sizeof (int)); submenu_end = (int *) alloca (subitems * sizeof (int)); submenu_n_panes = (int *) alloca (subitems * sizeof (int)); submenu_top_level_items = (int *) alloca (subitems * sizeof (int)); @@ -1037,7 +1037,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) submenu_end[i] = menu_items_used; } - last_i = i; + submenu_start[i] = -1; finish_menu_items (); /* Convert menu_items into widget_value trees @@ -1051,7 +1051,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) wv->help = Qnil; first_wv = wv; - for (i = 0; i < last_i; i++) + for (i = 0; 0 <= submenu_start[i]; i++) { menu_items_n_panes = submenu_n_panes[i]; wv = digest_single_submenu (submenu_start[i], submenu_end[i],