Skip to content

Commit 626df76

Browse files
peffgitster
authored andcommitted
fetch_refs_via_pack: free extra copy of refs
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3c17bf commit 626df76

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

transport.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static int fetch_refs_via_pack(struct transport *transport,
519519
int nr_heads, struct ref **to_fetch)
520520
{
521521
struct git_transport_data *data = transport->data;
522-
const struct ref *refs;
522+
struct ref *refs;
523523
char *dest = xstrdup(transport->url);
524524
struct fetch_pack_args args;
525525
struct ref *refs_tmp = NULL;
@@ -552,15 +552,17 @@ static int fetch_refs_via_pack(struct transport *transport,
552552
&transport->pack_lockfile);
553553
close(data->fd[0]);
554554
close(data->fd[1]);
555-
if (finish_connect(data->conn))
555+
if (finish_connect(data->conn)) {
556+
free_refs(refs);
556557
refs = NULL;
558+
}
557559
data->conn = NULL;
558560
data->got_remote_heads = 0;
559561
data->options.self_contained_and_connected =
560562
args.self_contained_and_connected;
561563

562564
free_refs(refs_tmp);
563-
565+
free_refs(refs);
564566
free(dest);
565567
return (refs ? 0 : -1);
566568
}

0 commit comments

Comments
 (0)