]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/difftool: plug several trivial memory leaks
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:43 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:36 +0000 (08:25 -0700)
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>
builtin/difftool.c
t/t7800-difftool.sh

index dcc68e190c25b47738bb7b59bfc8648339e810cb..1a68ab66993630510c0759fecf10ec8bb916128d 100644 (file)
@@ -660,6 +660,12 @@ finish:
        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);
index cc917b257e3bb82451d027d05dce9dd91825ec63..f67b9345b8a0130c48fec0add93526a9aee10190 100755 (executable)
@@ -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 ()