]> Kevux Git Server - rit/commitdiff
promisor-remote: fix leaking partial clone filter
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:57 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:36 +0000 (08:25 -0700)
The partial clone filter of a promisor remote is never free'd, causing
memory leaks. Furthermore, in case multiple partial clone filters are
defined for the same remote, we'd overwrite previous values without
freeing them.

Fix these leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
promisor-remote.c
t/t7814-grep-recurse-submodules.sh

index 317e1b1..9345ae3 100644 (file)
@@ -154,6 +154,7 @@ static int promisor_remote_config(const char *var, const char *value,
                if (!r)
                        return 0;
 
+               FREE_AND_NULL(r->partial_clone_filter);
                return git_config_string(&r->partial_clone_filter, var, value);
        }
 
@@ -189,6 +190,7 @@ void promisor_remote_clear(struct promisor_remote_config *config)
 {
        while (config->promisors) {
                struct promisor_remote *r = config->promisors;
+               free(r->partial_clone_filter);
                config->promisors = config->promisors->next;
                free(r);
        }
index 167fe66..55ed630 100755 (executable)
@@ -7,6 +7,7 @@ submodules.
 '
 
 TEST_CREATE_REPO_NO_TEMPLATE=1
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1