notes-utils: free note trees when releasing copied notes

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>

Patrick Steinhardt committed Jun 11, 2024 at 11:19 UTC bb8c43d5cd9648f868e11e462392a38a43354692
3 files changed +3
notes-utils.c
+1
@@ -187,6 +187,7 @@ void finish_copy_notes_for_rewrite(struct repository *r,
187 for (i = 0; c->trees[i]; i++) {
188 commit_notes(r, c->trees[i], msg);
189 free_notes(c->trees[i]);
190 + free(c->trees[i]);
191 }
192 free(c->trees);
193 free(c);
t/t3400-rebase.sh
+1
@@ -11,6 +11,7 @@ among other things.
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 GIT_AUTHOR_NAME=author@name
t/t7501-commit-basic-functionality.sh
+1
@@ -9,6 +9,7 @@ test_description='git commit'
9 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11
12 +TEST_PASSES_SANITIZE_LEAK=true
13 . ./test-lib.sh
14 . "$TEST_DIRECTORY/lib-diff.sh"
15