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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 19, 2015 at 16:38 UTC
626df76e3df3a0d8ecee07098706547648e6c96f
1 file changed
+5
-3
transport.c
+5
-3
@@ -519,7 +519,7 @@ static int fetch_refs_via_pack(struct transport *transport,
519
int nr_heads, struct ref **to_fetch)
520
{
521
struct git_transport_data *data = transport->data;
522
- const struct ref *refs;
522
+ struct ref *refs;
523
char *dest = xstrdup(transport->url);
524
struct fetch_pack_args args;
525
struct ref *refs_tmp = NULL;
@@ -552,15 +552,17 @@ static int fetch_refs_via_pack(struct transport *transport,
552
&transport->pack_lockfile);
553
close(data->fd[0]);
554
close(data->fd[1]);
555
- if (finish_connect(data->conn))
555
+ if (finish_connect(data->conn)) {
556
+ free_refs(refs);
557
refs = NULL;
558
+ }
559
data->conn = NULL;
560
data->got_remote_heads = 0;
561
data->options.self_contained_and_connected =
562
args.self_contained_and_connected;
563
564
free_refs(refs_tmp);
563
-
565
+ free_refs(refs);
566
free(dest);
567
return (refs ? 0 : -1);
568
}