]> git.ipfire.org Git - thirdparty/git.git/commitdiff
notes-utils: free note trees when releasing copied notes
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:19:26 +0000 (11:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:05 +0000 (13:15 -0700)
While we clear most of the members of `struct notes_rewrite_cfg` in
`finish_copy_notes_for_rewrite()`, we do not clear the notes tree. Fix
this to plug this memory leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes-utils.c
t/t3400-rebase.sh
t/t7501-commit-basic-functionality.sh

index e33aa86c4b9f736da765f79072a48a28c841d70b..671d1969b1f3ab0e5d24b8de996bd97c013263e4 100644 (file)
@@ -187,6 +187,7 @@ void finish_copy_notes_for_rewrite(struct repository *r,
        for (i = 0; c->trees[i]; i++) {
                commit_notes(r, c->trees[i], msg);
                free_notes(c->trees[i]);
+               free(c->trees[i]);
        }
        free(c->trees);
        free(c);
index e1c8c5f70110aacfaa778194093f2a79251e055c..ae34bfad6071fbb40973eb3b01f1d28e360aa0d9 100755 (executable)
@@ -11,6 +11,7 @@ among other things.
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 GIT_AUTHOR_NAME=author@name
index cc12f99f11534b898d11a0fc7bbb5d339730ccc8..52f5e28154e2ff797bf352ea916e92599912ac19 100755 (executable)
@@ -9,6 +9,7 @@ test_description='git commit'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-diff.sh"