aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu.c')
-rw-r--r--src/menu.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/menu.c b/src/menu.c
index 66247c713a2..8c624f758a9 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -632,8 +632,9 @@ digest_single_submenu (int start, int end, bool top_level_items)
632 widget_value **submenu_stack; 632 widget_value **submenu_stack;
633 bool panes_seen = 0; 633 bool panes_seen = 0;
634 struct frame *f = XFRAME (Vmenu_updating_frame); 634 struct frame *f = XFRAME (Vmenu_updating_frame);
635 USE_SAFE_ALLOCA;
635 636
636 submenu_stack = alloca (menu_items_used * sizeof *submenu_stack); 637 SAFE_NALLOCA (submenu_stack, 1, menu_items_used);
637 wv = make_widget_value ("menu", NULL, true, Qnil); 638 wv = make_widget_value ("menu", NULL, true, Qnil);
638 wv->button_type = BUTTON_TYPE_NONE; 639 wv->button_type = BUTTON_TYPE_NONE;
639 first_wv = wv; 640 first_wv = wv;
@@ -835,11 +836,12 @@ digest_single_submenu (int start, int end, bool top_level_items)
835 that was originally a button, return it by itself. */ 836 that was originally a button, return it by itself. */
836 if (top_level_items && first_wv->contents && first_wv->contents->next == 0) 837 if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
837 { 838 {
838 wv = first_wv->contents; 839 wv = first_wv;
839 xfree (first_wv); 840 first_wv = first_wv->contents;
840 return wv; 841 xfree (wv);
841 } 842 }
842 843
844 SAFE_FREE ();
843 return first_wv; 845 return first_wv;
844} 846}
845 847
@@ -890,9 +892,10 @@ find_and_call_menu_selection (struct frame *f, int menu_bar_items_used,
890 Lisp_Object *subprefix_stack; 892 Lisp_Object *subprefix_stack;
891 int submenu_depth = 0; 893 int submenu_depth = 0;
892 int i; 894 int i;
895 USE_SAFE_ALLOCA;
893 896
894 entry = Qnil; 897 entry = Qnil;
895 subprefix_stack = alloca (menu_bar_items_used * sizeof *subprefix_stack); 898 SAFE_NALLOCA (subprefix_stack, 1, menu_bar_items_used);
896 prefix = Qnil; 899 prefix = Qnil;
897 i = 0; 900 i = 0;
898 901
@@ -954,11 +957,13 @@ find_and_call_menu_selection (struct frame *f, int menu_bar_items_used,
954 buf.arg = entry; 957 buf.arg = entry;
955 kbd_buffer_store_event (&buf); 958 kbd_buffer_store_event (&buf);
956 959
957 return; 960 break;
958 } 961 }
959 i += MENU_ITEMS_ITEM_LENGTH; 962 i += MENU_ITEMS_ITEM_LENGTH;
960 } 963 }
961 } 964 }
965
966 SAFE_FREE ();
962} 967}
963 968
964#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || HAVE_NTGUI */ 969#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || HAVE_NTGUI */
@@ -973,10 +978,11 @@ find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data
973 int i; 978 int i;
974 Lisp_Object *subprefix_stack; 979 Lisp_Object *subprefix_stack;
975 int submenu_depth = 0; 980 int submenu_depth = 0;
981 USE_SAFE_ALLOCA;
976 982
977 prefix = entry = Qnil; 983 prefix = entry = Qnil;
978 i = 0; 984 i = 0;
979 subprefix_stack = alloca (menu_items_used * word_size); 985 SAFE_ALLOCA_LISP (subprefix_stack, menu_items_used);
980 986
981 while (i < menu_items_used) 987 while (i < menu_items_used)
982 { 988 {
@@ -1018,11 +1024,13 @@ find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data
1018 if (!NILP (subprefix_stack[j])) 1024 if (!NILP (subprefix_stack[j]))
1019 entry = Fcons (subprefix_stack[j], entry); 1025 entry = Fcons (subprefix_stack[j], entry);
1020 } 1026 }
1027 SAFE_FREE ();
1021 return entry; 1028 return entry;
1022 } 1029 }
1023 i += MENU_ITEMS_ITEM_LENGTH; 1030 i += MENU_ITEMS_ITEM_LENGTH;
1024 } 1031 }
1025 } 1032 }
1033 SAFE_FREE ();
1026 return Qnil; 1034 return Qnil;
1027} 1035}
1028#endif /* HAVE_NS */ 1036#endif /* HAVE_NS */