menu: invalidate nested duplicated menus

Prior to this commit, nesting the same menus caused stack overflow at
`close_all_submenus()` when trying to open it.
This commit is contained in:
tokyo4j 2024-11-14 00:25:49 +09:00 committed by Hiroaki Yamamoto
parent 3a7c6ce300
commit d7e6f3a7a8

View file

@ -663,6 +663,17 @@ handle_menu_element(xmlNode *n, struct server *server)
}
struct menu *menu = menu_get_by_id(server, id);
struct menu *iter = current_menu;
while (iter) {
if (iter == menu) {
wlr_log(WLR_ERROR, "menus with the same id '%s' "
"cannot be nested", id);
goto error;
}
iter = iter->parent;
}
if (menu) {
current_item = item_create(current_menu, menu->label, true);
if (current_item) {