Skip to content

Commit 355b319

Browse files
pks-tgitster
authored andcommitted
promisor-remote: fix leaking partial clone filter
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6d82437 commit 355b319

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

promisor-remote.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static int promisor_remote_config(const char *var, const char *value,
154154
if (!r)
155155
return 0;
156156

157+
FREE_AND_NULL(r->partial_clone_filter);
157158
return git_config_string(&r->partial_clone_filter, var, value);
158159
}
159160

@@ -189,6 +190,7 @@ void promisor_remote_clear(struct promisor_remote_config *config)
189190
{
190191
while (config->promisors) {
191192
struct promisor_remote *r = config->promisors;
193+
free(r->partial_clone_filter);
192194
config->promisors = config->promisors->next;
193195
free(r);
194196
}

t/t7814-grep-recurse-submodules.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ submodules.
77
'
88

99
TEST_CREATE_REPO_NO_TEMPLATE=1
10+
TEST_PASSES_SANITIZE_LEAK=true
1011
. ./test-lib.sh
1112

1213
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1

0 commit comments

Comments
 (0)