diff mbox series

[v2,06/22] submodule: fix leaking fetch task data

Message ID 872f39faece60cba10aeb4606fd3ff28b59ee568.1725530720.git.ps@pks.im (mailing list archive)
State Accepted
Commit 3eefd348e5865b0406d32194a157ae77d9a7939b
Headers show
Series Memory leak fixes (pt.6) | expand

Commit Message

Patrick Steinhardt Sept. 5, 2024, 10:08 a.m. UTC
The `submodule_parallel_fetch` structure contains various data
structures that we use to set up parallel fetches of submodules. We do
not free some of its data though, causing memory leaks. Plug those.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 submodule.c                 | 2 ++
 t/t5526-fetch-submodules.sh | 1 +
 2 files changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/submodule.c b/submodule.c
index 97516b0fec1..97d0d47b561 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1883,6 +1883,8 @@  int fetch_submodules(struct repository *r,
 out:
 	free_submodules_data(&spf.changed_submodule_names);
 	string_list_clear(&spf.seen_submodule_names, 0);
+	strbuf_release(&spf.submodules_with_errors);
+	free(spf.oid_fetch_tasks);
 	return spf.result;
 }
 
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index 5e566205ba4..2cfb5bd6bb1 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -6,6 +6,7 @@  test_description='Recursive "git fetch" for submodules'
 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 pwd=$(pwd)