menu: fix UAF of server->menu_current

This fixes segfault when exiting with a menu opened, which is a regression
from eaf11fac.
This commit is contained in:
tokyo4j 2024-11-13 23:57:42 +09:00 committed by Consolatis
parent 77d1747f1b
commit d5daee6b96

View file

@ -1140,6 +1140,10 @@ menu_free(struct menu *menu)
/* Keep items clean on pipemenu destruction */ /* Keep items clean on pipemenu destruction */
nullify_item_pointing_to_this_menu(menu); nullify_item_pointing_to_this_menu(menu);
if (menu->server->menu_current == menu) {
menu_close_root(menu->server);
}
struct menuitem *item, *next; struct menuitem *item, *next;
wl_list_for_each_safe(item, next, &menu->menuitems, link) { wl_list_for_each_safe(item, next, &menu->menuitems, link) {
item_destroy(item); item_destroy(item);