diff options
| author | Paul Eggert | 2011-05-12 09:16:40 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-05-12 09:16:40 -0700 |
| commit | 3e26f69c4f5f7fe38081f0889186d6a9260c85e0 (patch) | |
| tree | dc59eb2bb91f499ee07a432dc0d2ffebae6213f6 /src | |
| parent | 5cc152c0804748eb4c872ff34fe5414669e10745 (diff) | |
| download | emacs-3e26f69c4f5f7fe38081f0889186d6a9260c85e0.tar.gz emacs-3e26f69c4f5f7fe38081f0889186d6a9260c85e0.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/xmenu.c | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 913dcc05a10..3bdf5129da9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2011-05-12 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-05-12 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * xmenu.c (set_frame_menubar): Use int, not EMACS_UINT, for indexes | ||
| 4 | that always fit in int. Use a sentinel instead of a counter, to | ||
| 5 | avoid a temp and to allay GCC's concerns about possible int overflow. | ||
| 6 | |||
| 3 | * menu.c (grow_menu_items): Check for int overflow. | 7 | * menu.c (grow_menu_items): Check for int overflow. |
| 4 | 8 | ||
| 5 | * xmenu.c (set_frame_menubar): Don't mishandle vectors with no nils. | 9 | * 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) | |||
| 922 | #endif | 922 | #endif |
| 923 | Lisp_Object items; | 923 | Lisp_Object items; |
| 924 | widget_value *wv, *first_wv, *prev_wv = 0; | 924 | widget_value *wv, *first_wv, *prev_wv = 0; |
| 925 | EMACS_UINT i, last_i; | 925 | int i; |
| 926 | int *submenu_start, *submenu_end; | 926 | int *submenu_start, *submenu_end; |
| 927 | int *submenu_top_level_items, *submenu_n_panes; | 927 | int *submenu_top_level_items, *submenu_n_panes; |
| 928 | 928 | ||
| @@ -966,7 +966,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) | |||
| 966 | Lisp_Object *previous_items | 966 | Lisp_Object *previous_items |
| 967 | = (Lisp_Object *) alloca (previous_menu_items_used | 967 | = (Lisp_Object *) alloca (previous_menu_items_used |
| 968 | * sizeof (Lisp_Object)); | 968 | * sizeof (Lisp_Object)); |
| 969 | EMACS_UINT subitems; | 969 | int subitems; |
| 970 | 970 | ||
| 971 | /* If we are making a new widget, its contents are empty, | 971 | /* If we are making a new widget, its contents are empty, |
| 972 | do always reinitialize them. */ | 972 | do always reinitialize them. */ |
| @@ -1012,7 +1012,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) | |||
| 1012 | menu_items = f->menu_bar_vector; | 1012 | menu_items = f->menu_bar_vector; |
| 1013 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; | 1013 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; |
| 1014 | subitems = ASIZE (items) / 4; | 1014 | subitems = ASIZE (items) / 4; |
| 1015 | submenu_start = (int *) alloca (subitems * sizeof (int)); | 1015 | submenu_start = (int *) alloca ((subitems + 1) * sizeof (int)); |
| 1016 | submenu_end = (int *) alloca (subitems * sizeof (int)); | 1016 | submenu_end = (int *) alloca (subitems * sizeof (int)); |
| 1017 | submenu_n_panes = (int *) alloca (subitems * sizeof (int)); | 1017 | submenu_n_panes = (int *) alloca (subitems * sizeof (int)); |
| 1018 | submenu_top_level_items = (int *) alloca (subitems * sizeof (int)); | 1018 | 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) | |||
| 1037 | submenu_end[i] = menu_items_used; | 1037 | submenu_end[i] = menu_items_used; |
| 1038 | } | 1038 | } |
| 1039 | 1039 | ||
| 1040 | last_i = i; | 1040 | submenu_start[i] = -1; |
| 1041 | finish_menu_items (); | 1041 | finish_menu_items (); |
| 1042 | 1042 | ||
| 1043 | /* Convert menu_items into widget_value trees | 1043 | /* Convert menu_items into widget_value trees |
| @@ -1051,7 +1051,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) | |||
| 1051 | wv->help = Qnil; | 1051 | wv->help = Qnil; |
| 1052 | first_wv = wv; | 1052 | first_wv = wv; |
| 1053 | 1053 | ||
| 1054 | for (i = 0; i < last_i; i++) | 1054 | for (i = 0; 0 <= submenu_start[i]; i++) |
| 1055 | { | 1055 | { |
| 1056 | menu_items_n_panes = submenu_n_panes[i]; | 1056 | menu_items_n_panes = submenu_n_panes[i]; |
| 1057 | wv = digest_single_submenu (submenu_start[i], submenu_end[i], | 1057 | wv = digest_single_submenu (submenu_start[i], submenu_end[i], |