]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: ignore <item> without parent <menu>
authorJohan Malm <jgm323@gmail.com>
Thu, 13 Jun 2024 20:00:44 +0000 (21:00 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 13 Jun 2024 21:17:16 +0000 (23:17 +0200)
...to avoid assert() in item_create() because current_menu is NULL.

Reproduce crash with...

    <?xml version="1.0" encoding="utf-8"?>
    <openbox_menu>
      <item label="foo"/>
    </openbox_menu>

src/menu/menu.c

index a30fcba2c3112b3bc4c1f19249379f51eb457ce5..9342ab28c8e5cc26cbb4e67af46f07be5159adc9 100644 (file)
@@ -605,6 +605,11 @@ xml_tree_walk(xmlNode *node, struct server *server)
                        continue;
                }
                if (!strcasecmp((char *)n->name, "item")) {
+                       if (!current_menu) {
+                               wlr_log(WLR_ERROR,
+                                       "ignoring <item> without parent <menu>");
+                               continue;
+                       }
                        in_item = true;
                        traverse(n, server);
                        in_item = false;