Skip to content

Commit

Permalink
fix(studio): Ensure null-termination of layer name read from settings
Browse files Browse the repository at this point in the history
This fixes the string leak when a layer name is changed to a longer one,
but is discarded and reverted to the original shorter one from ZMK Studio.
  • Loading branch information
xingrz committed Sep 14, 2024
1 parent 67d595f commit 8aef1a1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ static int keymap_handle_set(const char *name, size_t len, settings_read_cb read
LOG_ERR("Failed to handle keymap layer name from settings (err %d)", err);
return err;
}

zmk_keymap_layer_names[layer][len] = 0;
} else if (settings_name_steq(name, "l", &next) && next) {
char *endptr;
uint8_t layer = strtoul(next, &endptr, 10);
Expand Down

0 comments on commit 8aef1a1

Please sign in to comment.