]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/config/rcxml.c: ensure parent action is available
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 22 May 2024 01:36:33 +0000 (03:36 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 22 May 2024 06:12:03 +0000 (07:12 +0100)
Before this patch, having a branch or query with an invalid or
missing parent action would trigger an assert when trying to
access the parent. This patch ensures that we bail out instead.

Reported-by: fuyukai via IRC (thanks)
src/config/rcxml.c

index 164e329ccb9671b68eb9e18a91f3747b8c1e776a..4af7ed464c44bbe7e694bfc6bc5aacc9ca2b86c0 100644 (file)
@@ -289,6 +289,11 @@ fill_region(char *nodename, char *content)
 static void
 fill_action_query(char *nodename, char *content, struct action *action)
 {
+       if (!action) {
+               wlr_log(WLR_ERROR, "No parent action for query: %s=%s", nodename, content);
+               return;
+       }
+
        string_truncate_at_pattern(nodename, ".keybind.keyboard");
        string_truncate_at_pattern(nodename, ".mousebind.context.mouse");
 
@@ -325,6 +330,11 @@ static void
 fill_child_action(char *nodename, char *content, struct action *parent,
        const char *branch_name)
 {
+       if (!parent) {
+               wlr_log(WLR_ERROR, "No parent action for branch: %s=%s", nodename, content);
+               return;
+       }
+
        string_truncate_at_pattern(nodename, ".keybind.keyboard");
        string_truncate_at_pattern(nodename, ".mousebind.context.mouse");
        string_truncate_at_pattern(nodename, ".then.action");