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
This commit is contained in:
Daniel Eklöf 2024-02-24 09:58:04 +01:00
parent a5ab490380
commit 3d9aa1c29c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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;
}