[ui] Free the label when freeing the state

Plugs a memory leak.
This commit is contained in:
Bill Currie 2023-07-04 17:24:45 +09:00
parent 104fba13a6
commit a92754caf1

View file

@ -121,11 +121,11 @@ imui_get_state (imui_ctx_t *ctx, const char *label)
uint32_t label_len = ~0u; uint32_t label_len = ~0u;
const char *key = strstr (label, "##"); const char *key = strstr (label, "##");
if (key) { if (key) {
label_len = key - label;
// key is '###': hash only past this // key is '###': hash only past this
if (key[2] == '#') { if (key[2] == '#') {
key_offset = (key += 3) - label; key_offset = (key += 3) - label;
} }
label_len = key - label;
} }
imui_state_t *state = Hash_Find (ctx->tab, label + key_offset); imui_state_t *state = Hash_Find (ctx->tab, label + key_offset);
if (state) { if (state) {
@ -250,6 +250,7 @@ prune_objects (imui_ctx_t *ctx)
s = &(*s)->next; s = &(*s)->next;
} else { } else {
Hash_Del (ctx->tab, (*s)->label + (*s)->key_offset); Hash_Del (ctx->tab, (*s)->label + (*s)->key_offset);
free ((*s)->label);
imui_state_free (ctx, *s); imui_state_free (ctx, *s);
} }
} }