Skip to content

Commit 74a06a9

Browse files
avargitster
authored andcommitted
clone: fix memory leak in wanted_peer_refs()
Fix a memory leak added in 0ec4b16 (clone: fix ref selection in --single-branch --branch=xxx, 2012-06-22). Whether we get our "remote_head" from copy_ref() directly, or with a call to guess_remote_head() it'll be the result of a copy_ref() in either case, as guess_remote_head() is a wrapper for copy_ref() (or it returns NULL). We can't mark any tests passing passing with SANITIZE=leak using "TEST_PASSES_SANITIZE_LEAK=true" as a result of this change, but e.g. "t/t1500-rev-parse.sh" now gets closer to passing. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 99b6c45 commit 74a06a9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

builtin/clone.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
494494
/* if --branch=tag, pull the requested tag explicitly */
495495
get_fetch_map(remote_head, tag_refspec, &tail, 0);
496496
}
497+
free_refs(remote_head);
497498
} else {
498499
int i;
499500
for (i = 0; i < refspec->nr; i++)

0 commit comments

Comments
 (0)