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>

Johannes Schindelin committed May 4, 2017 at 15:59 UTC 3dc7ea91dab9959b6bec82c05df18d6d1bb70619
1 file changed +3 -2
remote.c
+3 -2
@@ -1191,9 +1191,10 @@ static int match_explicit(struct ref *src, struct ref *dst,
1191 else if (is_null_oid(&matched_src->new_oid))
1192 error("unable to delete '%s': remote ref does not exist",
1193 dst_value);
1194 - else if ((dst_guess = guess_ref(dst_value, matched_src)))
1194 + else if ((dst_guess = guess_ref(dst_value, matched_src))) {
1195 matched_dst = make_linked_ref(dst_guess, dst_tail);
1196 - else
1196 + free(dst_guess);
1197 + } else
1198 error("unable to push to unqualified destination: %s\n"
1199 "The destination refspec neither matches an "
1200 "existing ref on the remote nor\n"