menu: ignore <item> without parent <menu>

...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>
This commit is contained in:
Johan Malm 2024-06-13 21:00:44 +01:00 committed by Consolatis
parent dc27be2471
commit 4ee538c6cd

View file

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