From: tokyo4j Date: Sun, 3 Aug 2025 07:55:59 +0000 (+0900) Subject: menu: fix segfault with toplevel X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=03004cf44b2c2f1f4f42a8263dc214a60774d546;p=proto%2Flabwc.git menu: fix segfault with toplevel Before this patch, labwc crashed menu.xml like this: --- diff --git a/src/menu/menu.c b/src/menu/menu.c index dd902bc2..8d80231f 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -269,6 +269,8 @@ item_create_scene(struct menuitem *menuitem, int *item_y) static struct menuitem * separator_create(struct menu *menu, const char *label) { + assert(menu); + struct menuitem *menuitem = znew(*menuitem); menuitem->parent = menu; menuitem->selectable = false; @@ -754,6 +756,11 @@ xml_tree_walk(struct menu_parse_context *ctx, xmlNode *node) continue; } if (!strcasecmp((char *)n->name, "separator")) { + if (!ctx->menu) { + wlr_log(WLR_ERROR, + "ignoring without parent "); + continue; + } handle_separator_element(ctx, n); continue; }