summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2017-05-04 15:59:01 +0200
committerJunio C Hamano <gitster@pobox.com>2017-05-08 12:18:20 +0900
commit3dc7ea91dab9959b6bec82c05df18d6d1bb70619 (patch)
tree426a40798e6cb66311ae38a89bd46cc5004a87c3 /remote.c
parent5026b471751092ab971f3d4ae46320bc8ce40ff5 (diff)
downloadgit-3dc7ea91dab9959b6bec82c05df18d6d1bb70619.tar.gz
remote: plug memory leak in match_explicit()
The `guess_ref()` returns an allocated buffer of which `make_linked_ref()` does not take custody (`alloc_ref()` makes a copy), therefore we need to release the buffer afterwards. Noticed via Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/remote.c b/remote.c
index 801137c72e..72b4591b98 100644
--- a/remote.c
+++ b/remote.c
@@ -1191,9 +1191,10 @@ static int match_explicit(struct ref *src, struct ref *dst,
else if (is_null_oid(&matched_src->new_oid))
error("unable to delete '%s': remote ref does not exist",
dst_value);
- else if ((dst_guess = guess_ref(dst_value, matched_src)))
+ else if ((dst_guess = guess_ref(dst_value, matched_src))) {
matched_dst = make_linked_ref(dst_guess, dst_tail);
- else
+ free(dst_guess);
+ } else
error("unable to push to unqualified destination: %s\n"
"The destination refspec neither matches an "
"existing ref on the remote nor\n"