menu: fix crash triggered by pipemenu without parent <menu>

...such as the one in the example below:

    <?xml version="1.0" encoding="UTF-8"?>
    <openbox_menu>
      <menu id="root-menu" label="obmenu-generator" execute="obmenu-generator"/>
    </openbox_menu>

We should consider supporting this construct in future.

Reported-by: cry0xen via IRC
This commit is contained in:
Johan Malm 2024-07-15 21:47:10 +01:00 committed by Consolatis
parent 5a6a72da36
commit 7756d5b975

View file

@ -506,6 +506,23 @@ handle_menu_element(xmlNode *n, struct server *server)
if (execute && label && id) {
wlr_log(WLR_DEBUG, "pipemenu '%s:%s:%s'", id, label, execute);
if (!current_menu) {
/*
* We currently do not support pipemenus without a
* parent <item> such as the one the example below:
*
* <?xml version="1.0" encoding="UTF-8"?>
* <openbox_menu>
* <menu id="root-menu" label="foo" execute="bar"/>
* </openbox_menu>
*
* TODO: Consider supporting this
*/
wlr_log(WLR_ERROR,
"pipemenu '%s:%s:%s' has no parent <menu>",
id, label, execute);
goto error;
}
current_item = item_create(current_menu, label, /* arrow */ true);
current_item_action = NULL;
current_item->execute = xstrdup(execute);