提交 3dc7ea91 编写于 作者: J Johannes Schindelin 提交者: Junio C Hamano

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: NJohannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 5026b471
...@@ -1191,9 +1191,10 @@ static int match_explicit(struct ref *src, struct ref *dst, ...@@ -1191,9 +1191,10 @@ static int match_explicit(struct ref *src, struct ref *dst,
else if (is_null_oid(&matched_src->new_oid)) else if (is_null_oid(&matched_src->new_oid))
error("unable to delete '%s': remote ref does not exist", error("unable to delete '%s': remote ref does not exist",
dst_value); 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); matched_dst = make_linked_ref(dst_guess, dst_tail);
else free(dst_guess);
} else
error("unable to push to unqualified destination: %s\n" error("unable to push to unqualified destination: %s\n"
"The destination refspec neither matches an " "The destination refspec neither matches an "
"existing ref on the remote nor\n" "existing ref on the remote nor\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册