Skip to content

Commit 8909d6e

Browse files
pks-tgitster
authored andcommitted
builtin/clone: plug leaking HEAD ref in wanted_peer_refs()
In `wanted_peer_refs()` we first create a copy of the "HEAD" ref. This copy may not actually be passed back to the caller, but is not getting freed in this case. Fix this. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4806c55 commit 8909d6e

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

builtin/clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
530530
if (!option_branch)
531531
remote_head = guess_remote_head(head, refs, 0);
532532
else {
533-
local_refs = NULL;
533+
free_one_ref(head);
534+
local_refs = head = NULL;
534535
tail = &local_refs;
535536
remote_head = copy_ref(find_remote_branch(refs, option_branch));
536537
}

t/t5300-pack-object.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Copyright (c) 2005 Junio C Hamano
44
#
55

6-
test_description='git pack-object
6+
test_description='git pack-object'
77

8-
'
8+
TEST_PASSES_SANITIZE_LEAK=true
99
. ./test-lib.sh
1010

1111
test_expect_success 'setup' '

t/t5305-include-tag.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='git pack-object --include-tag'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
TRASH=$(pwd)

t/t5612-clone-refspec.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='test refspec written by clone-command'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
test_expect_success 'setup' '

0 commit comments

Comments
 (0)