]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: invalidate nested duplicated menus
authortokyo4j <hrak1529@gmail.com>
Wed, 13 Nov 2024 15:25:49 +0000 (00:25 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Wed, 13 Nov 2024 20:28:06 +0000 (05:28 +0900)
Prior to this commit, nesting the same menus caused stack overflow at
`close_all_submenus()` when trying to open it.

src/menu/menu.c

index 045d310a5405bda31b3e17bf6c384b3c77bdff30..966601eb5a3e3136123a87f84e54b0f9c01331a9 100644 (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) {