]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: fix crash triggered by pipemenu without parent <menu>
authorJohan Malm <jgm323@gmail.com>
Mon, 15 Jul 2024 20:47:10 +0000 (21:47 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 15 Jul 2024 21:00:11 +0000 (22:00 +0100)
...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
src/menu/menu.c

index 8f55808c3411dbc08ce79c96044d3e7e7f155c3b..143a82330b2cce9c6f914cf6e8eb12d9d364901c 100644 (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);