Skip to content

Commit 16c6fb5

Browse files
pks-tgitster
authored andcommitted
shallow: fix leaking members of struct shallow_info
We do not free several struct members in `clear_shallow_info()`. Fix this to plug the resulting leaks. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14c0ea0 commit 16c6fb5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

shallow.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
489489

490490
void clear_shallow_info(struct shallow_info *info)
491491
{
492+
if (info->used_shallow) {
493+
for (size_t i = 0; i < info->shallow->nr; i++)
494+
free(info->used_shallow[i]);
495+
free(info->used_shallow);
496+
}
497+
498+
free(info->need_reachability_test);
499+
free(info->reachable);
500+
free(info->shallow_ref);
492501
free(info->ours);
493502
free(info->theirs);
494503
}

t/t5538-push-shallow.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='push from/to a shallow clone'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
commit() {

0 commit comments

Comments
 (0)