diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-06-11 11:20:57 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-06-11 13:15:07 -0700 |
| commit | 8909d6e1a108a46ae9cde70587aa8b2ad4a067d9 (patch) | |
| tree | 82b63c8c2f29a47986e0b639cf97a43b1a0e0df6 /builtin/clone.c | |
| parent | 4806c55c86f7cc45f60a7ff5d757874072265deb (diff) | |
| download | git-8909d6e1a108a46ae9cde70587aa8b2ad4a067d9.tar.xz | |
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>
Diffstat (limited to 'builtin/clone.c')
| -rw-r--r-- | builtin/clone.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index 730b3efae6..ae9863ed47 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -530,7 +530,8 @@ static struct ref *wanted_peer_refs(const struct ref *refs, if (!option_branch) remote_head = guess_remote_head(head, refs, 0); else { - local_refs = NULL; + free_one_ref(head); + local_refs = head = NULL; tail = &local_refs; remote_head = copy_ref(find_remote_branch(refs, option_branch)); } |
