diff --git a/ref-filter.c b/ref-filter.c index 791f0648a6..1c1a2af880 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2105,7 +2105,9 @@ static void free_array_item(struct ref_array_item *item) { free((char *)item->symref); if (item->value) { - free((char *)item->value->s); + int i; + for (i = 0; i < used_atom_cnt; i++) + free((char *)item->value[i].s); free(item->value); } free(item); @@ -2116,14 +2118,16 @@ void ref_array_clear(struct ref_array *array) { int i; - for (i = 0; i < used_atom_cnt; i++) - free((char *)used_atom[i].name); - FREE_AND_NULL(used_atom); - used_atom_cnt = 0; for (i = 0; i < array->nr; i++) free_array_item(array->items[i]); FREE_AND_NULL(array->items); array->nr = array->alloc = 0; + + for (i = 0; i < used_atom_cnt; i++) + free((char *)used_atom[i].name); + FREE_AND_NULL(used_atom); + used_atom_cnt = 0; + if (ref_to_worktree_map.worktrees) { hashmap_free(&(ref_to_worktree_map.map), 1); free_worktrees(ref_to_worktree_map.worktrees);