aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-02-24 08:58:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-02-24 08:58:04 +0000
commit3d9aa1c29cae7a493cb87055e6dfee92f0ff88c5 (patch)
tree41d82328188e614103f9c5501b7b8f28edf2003d
parentci: remove deprecated 'group' (diff)
config: don't try to free key combos we haven't allocated
When erroring out due to a key combo being "empty", we incorrectly tried to free one key binding. This is because 'used_combos' is initialized to '1'. And it should, but an empty key binding is a special case. Fixes a test failure, and closes #1620
-rw-r--r--config.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/config.c b/config.c
index 74aaca4e..ab0e2927 100644
--- a/config.c
+++ b/config.c
@@ -1823,8 +1823,10 @@ value_to_key_combos(struct context *ctx, int action,
return true;
err:
- for (size_t i = 0; i < used_combos; i++)
- free_key_binding(&new_combos[i]);
+ if (idx > 0) {
+ for (size_t i = 0; i < used_combos; i++)
+ free_key_binding(&new_combos[i]);
+ }
free(copy);
return false;
}