From: Eli Zaretskii Date: Mon, 23 May 2022 13:54:17 +0000 (+0300) Subject: * src/w32menu.c (w32_menu_show): Use SAFE_ALLOCA. (Bug#55068) X-Git-Tag: emacs-29.0.90~1910^2~477 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b3e4526f21749305b7f6b3f4a18e0df7cd0044a4;p=emacs.git * src/w32menu.c (w32_menu_show): Use SAFE_ALLOCA. (Bug#55068) --- diff --git a/src/w32menu.c b/src/w32menu.c index 5cd6c3310e3..b10239d5cc6 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -556,10 +556,8 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags, HMENU menu; POINT pos; widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; - widget_value **submenu_stack - = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); - Lisp_Object *subprefix_stack - = (Lisp_Object *) alloca (menu_items_used * word_size); + widget_value **submenu_stack; + Lisp_Object *subprefix_stack; int submenu_depth = 0; bool first_pane; @@ -574,6 +572,11 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags, return Qnil; } + USE_SAFE_ALLOCA; + + submenu_stack = SAFE_ALLOCA (menu_items_used * sizeof (widget_value *)); + subprefix_stack = SAFE_ALLOCA (menu_items_used * word_size); + block_input (); /* Create a tree of widget_value objects @@ -816,6 +819,7 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags, entry = Fcons (subprefix_stack[j], entry); } unblock_input (); + SAFE_FREE (); return entry; } i += MENU_ITEMS_ITEM_LENGTH; @@ -830,6 +834,7 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags, } unblock_input (); + SAFE_FREE (); return Qnil; }