From 626df76e3df3a0d8ecee07098706547648e6c96f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 19 Mar 2015 16:38:35 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- transport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'transport.c') diff --git a/transport.c b/transport.c index 70d38e4c4b..2e11f8ea82 100644 --- a/transport.c +++ b/transport.c @@ -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; @@ -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); } -- cgit v1.2.1