summaryrefslogtreecommitdiff
path: root/ref-filter.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-08-04 20:28:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-08-04 20:28:52 (GMT)
commit31f9acf9ce29ae210b54997f7fb388a2dc543d53 (patch)
treeec42e72471831dd47a31bd467e32b4bce6499be7 /ref-filter.c
parent10f57e0eb9070bf00c45def2980a47eacbae8316 (diff)
parent9a863b3358b84c627c8129defb9c127ec73e8e30 (diff)
downloadgit-31f9acf9ce29ae210b54997f7fb388a2dc543d53.zip
git-31f9acf9ce29ae210b54997f7fb388a2dc543d53.tar.gz
git-31f9acf9ce29ae210b54997f7fb388a2dc543d53.tar.bz2
Merge branch 'ah/plugleaks'
Leak plugging. * ah/plugleaks: reset: clear_unpack_trees_porcelain to plug leak builtin/rebase: fix options.strategy memory lifecycle builtin/merge: free found_ref when done builtin/mv: free or UNLEAK multiple pointers at end of cmd_mv convert: release strbuf to avoid leak read-cache: call diff_setup_done to avoid leak ref-filter: also free head for ATOM_HEAD to avoid leak diffcore-rename: move old_dir/new_dir definition to plug leak builtin/for-each-repo: remove unnecessary argv copy to plug leak builtin/submodule--helper: release unused strbuf to avoid leak environment: move strbuf into block to plug leak fmt-merge-msg: free newly allocated temporary strings when done
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ref-filter.c b/ref-filter.c
index f45d3a1..0cfef7b 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2226,8 +2226,12 @@ void ref_array_clear(struct ref_array *array)
FREE_AND_NULL(array->items);
array->nr = array->alloc = 0;
- for (i = 0; i < used_atom_cnt; i++)
- free((char *)used_atom[i].name);
+ for (i = 0; i < used_atom_cnt; i++) {
+ struct used_atom *atom = &used_atom[i];
+ if (atom->atom_type == ATOM_HEAD)
+ free(atom->u.head);
+ free((char *)atom->name);
+ }
FREE_AND_NULL(used_atom);
used_atom_cnt = 0;