submodule: fix leaking seen submodule names

We keep track of submodules we have already seen via a string map such that we don't process the same submodule twice. We never free that map though, causing a memory leak. Fix this leak by clearing the map. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 8, 2024 at 09:35 UTC fa0f27a19d4e2606ec24d9d4aed4f6c8df986370
3 files changed +3
submodule.c
+1
@@ -1880,6 +1880,7 @@ int fetch_submodules(struct repository *r,
1880 strvec_clear(&spf.args);
1881 out:
1882 free_submodules_data(&spf.changed_submodule_names);
1883 + string_list_clear(&spf.seen_submodule_names, 0);
1884 return spf.result;
1885 }
1886
t/t5572-pull-submodule.sh
+1
@@ -5,6 +5,7 @@ test_description='pull can handle submodules'
5 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
6 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
7
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/lib-submodule-update.sh
11
t/t7418-submodule-sparse-gitmodules.sh
+1
@@ -15,6 +15,7 @@ also by committing .gitmodules and then just removing it from the filesystem.
15 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
16 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
17
18 +TEST_PASSES_SANITIZE_LEAK=true
19 . ./test-lib.sh
20
21 test_expect_success 'setup' '