Skip to content

Commit 75e632d

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 <[email protected]>
1 parent 2e6904a commit 75e632d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

remote.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,10 @@ static int match_explicit(struct ref *src, struct ref *dst,
11911191
else if (is_null_oid(&matched_src->new_oid))
11921192
error("unable to delete '%s': remote ref does not exist",
11931193
dst_value);
1194-
else if ((dst_guess = guess_ref(dst_value, matched_src)))
1194+
else if ((dst_guess = guess_ref(dst_value, matched_src))) {
11951195
matched_dst = make_linked_ref(dst_guess, dst_tail);
1196-
else
1196+
free(dst_guess);
1197+
} else
11971198
error("unable to push to unqualified destination: %s\n"
11981199
"The destination refspec neither matches an "
11991200
"existing ref on the remote nor\n"

0 commit comments

Comments
 (0)