src/config/rcxml.c: ensure parent action is available

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)
This commit is contained in:
Consolatis 2024-05-22 03:36:33 +02:00 committed by Johan Malm
parent 23b96ad2a6
commit a7298314a4

View file

@ -289,6 +289,11 @@ fill_region(char *nodename, char *content)
static void static void
fill_action_query(char *nodename, char *content, struct action *action) 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, ".keybind.keyboard");
string_truncate_at_pattern(nodename, ".mousebind.context.mouse"); string_truncate_at_pattern(nodename, ".mousebind.context.mouse");
@ -325,6 +330,11 @@ static void
fill_child_action(char *nodename, char *content, struct action *parent, fill_child_action(char *nodename, char *content, struct action *parent,
const char *branch_name) 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, ".keybind.keyboard");
string_truncate_at_pattern(nodename, ".mousebind.context.mouse"); string_truncate_at_pattern(nodename, ".mousebind.context.mouse");
string_truncate_at_pattern(nodename, ".then.action"); string_truncate_at_pattern(nodename, ".then.action");