]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule: fix leaking seen submodule names
authorPatrick Steinhardt <ps@pks.im>
Thu, 8 Aug 2024 07:35:56 +0000 (09:35 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Aug 2024 16:22:21 +0000 (09:22 -0700)
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>
submodule.c
t/t5572-pull-submodule.sh
t/t7418-submodule-sparse-gitmodules.sh

index f027a6455ebeb8f79b7b7bd5ddcb746f427d9576..13b8f8c19c01867b4c7b9e4aa17a1dc3eb89caf1 100644 (file)
@@ -1880,6 +1880,7 @@ int fetch_submodules(struct repository *r,
        strvec_clear(&spf.args);
 out:
        free_submodules_data(&spf.changed_submodule_names);
+       string_list_clear(&spf.seen_submodule_names, 0);
        return spf.result;
 }
 
index 51744521f789b654ffbcee73afba47a0ecbe7e35..916e58c16696ba2676c3eb90e377c455f29c4016 100755 (executable)
@@ -5,6 +5,7 @@ test_description='pull can handle submodules'
 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-submodule-update.sh
 
index dde11ecce806c43272bdc59c6eb73a7c6ce241ad..e1d9bf2ee30d0ce840a1b213f54e84401bb7c809 100755 (executable)
@@ -15,6 +15,7 @@ also by committing .gitmodules and then just removing it from the filesystem.
 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
 export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '