Skip to content

Commit

Permalink
builtin/difftool: plug several trivial memory leaks
Browse files Browse the repository at this point in the history
There are several leaking data structures in git-difftool(1). Plug them.

Signed-off-by: Patrick Steinhardt <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
pks-t authored and gitster committed Sep 27, 2024
1 parent dea4a95 commit 7f795a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/difftool.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
if (fp)
fclose(fp);

hashmap_clear_and_free(&working_tree_dups, struct working_tree_entry, entry);
hashmap_clear_and_free(&wt_modified, struct path_entry, entry);
hashmap_clear_and_free(&tmp_modified, struct path_entry, entry);
hashmap_clear_and_free(&submodules, struct pair_entry, entry);
hashmap_clear_and_free(&symlinks2, struct pair_entry, entry);
release_index(&wtindex);
free(lbase_dir);
free(rbase_dir);
strbuf_release(&info);
Expand Down
1 change: 1 addition & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Testing basic diff tool invocation
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

difftool_test_setup ()
Expand Down

0 comments on commit 7f795a1

Please sign in to comment.