diff mbox series

[03/29] notes-utils: free note trees when releasing copied notes

Message ID 17a8f532752e005601b1cff5690a4dae16096b8b.1717402439.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series Memory leak fixes (pt.2) | expand

Commit Message

Patrick Steinhardt June 3, 2024, 9:46 a.m. UTC
While we clear most of the members of `struct notet_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>
---
 notes-utils.c                         | 1 +
 t/t3400-rebase.sh                     | 1 +
 t/t7501-commit-basic-functionality.sh | 1 +
 3 files changed, 3 insertions(+)

Comments

karthik nayak June 6, 2024, 10:02 a.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> While we clear most of the members of `struct notet_rewrite_cfg` in
> `finish_copy_notes_for_rewrite()`, we do not clear the notes tree. Fix
> this to plug this memory leak.
>

Nit: s/notet_rewrite_cfg/notes_rewrite_cfg

The commit itself looks good.
diff mbox series

Patch

diff --git a/notes-utils.c b/notes-utils.c
index e33aa86c4b..671d1969b1 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -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);
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index e1c8c5f701..ae34bfad60 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -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
diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
index cc12f99f11..52f5e28154 100755
--- a/t/t7501-commit-basic-functionality.sh
+++ b/t/t7501-commit-basic-functionality.sh
@@ -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"