Skip to content

Commit 7f795a1

Browse files
pks-tgitster
authored andcommitted
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>
1 parent dea4a95 commit 7f795a1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

builtin/difftool.c

+6
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
660660
if (fp)
661661
fclose(fp);
662662

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);
663669
free(lbase_dir);
664670
free(rbase_dir);
665671
strbuf_release(&info);

t/t7800-difftool.sh

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Testing basic diff tool invocation
1111
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1212
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1313

14+
TEST_PASSES_SANITIZE_LEAK=true
1415
. ./test-lib.sh
1516

1617
difftool_test_setup ()

0 commit comments

Comments
 (0)