From 3d9aa1c29cae7a493cb87055e6dfee92f0ff88c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 24 Feb 2024 09:58:04 +0100 Subject: [PATCH] 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 --- config.c | 6 ++++-- 1 file 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; }