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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
4806c55c86
commit
8909d6e1a1
@ -530,7 +530,8 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
|
|||||||
if (!option_branch)
|
if (!option_branch)
|
||||||
remote_head = guess_remote_head(head, refs, 0);
|
remote_head = guess_remote_head(head, refs, 0);
|
||||||
else {
|
else {
|
||||||
local_refs = NULL;
|
free_one_ref(head);
|
||||||
|
local_refs = head = NULL;
|
||||||
tail = &local_refs;
|
tail = &local_refs;
|
||||||
remote_head = copy_ref(find_remote_branch(refs, option_branch));
|
remote_head = copy_ref(find_remote_branch(refs, option_branch));
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
# Copyright (c) 2005 Junio C Hamano
|
# Copyright (c) 2005 Junio C Hamano
|
||||||
#
|
#
|
||||||
|
|
||||||
test_description='git pack-object
|
test_description='git pack-object'
|
||||||
|
|
||||||
'
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
|
@ -4,6 +4,7 @@ test_description='git pack-object --include-tag'
|
|||||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
TRASH=$(pwd)
|
TRASH=$(pwd)
|
||||||
|
@ -4,6 +4,7 @@ test_description='test refspec written by clone-command'
|
|||||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
|
Reference in New Issue
Block a user