builtin/difftool: plug several trivial memory leaks
There are several leaking data structures in git-difftool(1). Plug them. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Sep 26, 2024 at 13:46 UTC
7f795a17154a2aeb80a7f52bfdaeef14fe298d68
2 files changed
+7
builtin/difftool.c
+6
@@ -660,6 +660,12 @@ finish:
660
if (fp)
661
fclose(fp);
662
663
+ hashmap_clear_and_free(&working_tree_dups, struct working_tree_entry, entry);
664
+ hashmap_clear_and_free(&wt_modified, struct path_entry, entry);
665
+ hashmap_clear_and_free(&tmp_modified, struct path_entry, entry);
666
+ hashmap_clear_and_free(&submodules, struct pair_entry, entry);
667
+ hashmap_clear_and_free(&symlinks2, struct pair_entry, entry);
668
+ release_index(&wtindex);
669
free(lbase_dir);
670
free(rbase_dir);
671
strbuf_release(&info);
t/t7800-difftool.sh
+1
@@ -11,6 +11,7 @@ Testing basic diff tool invocation
11
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
12
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13
14
+TEST_PASSES_SANITIZE_LEAK=true
15
. ./test-lib.sh
16
17
difftool_test_setup ()