diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-07-19 11:30:23 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-19 11:30:23 -0700 |
commit | 8619522ad1670ea82c0895f2bfe6c75e06df32e7 (patch) | |
tree | d7cdea6b6a16b4e693296a69cf33032a6f5bae41 | |
parent | Merge branch 'js/trace2-signo-typofix' (diff) | |
parent | ref-filter: fix memory leak in `free_array_item()` (diff) | |
download | tgif-8619522ad1670ea82c0895f2bfe6c75e06df32e7.tar.xz |
Merge branch 'ma/ref-filter-leakfix'
Leakfix.
* ma/ref-filter-leakfix:
ref-filter: fix memory leak in `free_array_item()`
-rw-r--r-- | ref-filter.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ref-filter.c b/ref-filter.c index 56528caafd..f27cfc8c3e 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2142,7 +2142,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); @@ -2153,14 +2155,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); |