Skip to content

Commit

Permalink
fetch_refs_via_pack: free extra copy of refs
Browse files Browse the repository at this point in the history
When fetch_refs_via_pack calls fetch_pack(), we pass a
list of refs to fetch, and the function returns either a
copy of that list, with the fetched items filled in, or
NULL. We check the return value to see whether the fetch was
successful, but do not otherwise look at the copy, and
simply leak it at the end of the function.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 19, 2015
1 parent c3c17bf commit 626df76
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static int fetch_refs_via_pack(struct transport *transport,
int nr_heads, struct ref **to_fetch)
{
struct git_transport_data *data = transport->data;
const struct ref *refs;
struct ref *refs;
char *dest = xstrdup(transport->url);
struct fetch_pack_args args;
struct ref *refs_tmp = NULL;
Expand Down Expand Up @@ -552,15 +552,17 @@ static int fetch_refs_via_pack(struct transport *transport,
&transport->pack_lockfile);
close(data->fd[0]);
close(data->fd[1]);
if (finish_connect(data->conn))
if (finish_connect(data->conn)) {
free_refs(refs);
refs = NULL;
}
data->conn = NULL;
data->got_remote_heads = 0;
data->options.self_contained_and_connected =
args.self_contained_and_connected;

free_refs(refs_tmp);

free_refs(refs);
free(dest);
return (refs ? 0 : -1);
}
Expand Down

0 comments on commit 626df76

Please sign in to comment.