Fix memory leak in helper method for disconnect

Since some cases may need to disconnect from the helper and reconnect,
wrap the function that just disconnects in a function that also frees
transport->data.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Daniel Barkalow 2009-11-18 02:42:21 +01:00 committed by Junio C Hamano
parent cd0f8e6d63
commit f2a37151d4

View File

@ -67,6 +67,13 @@ static int disconnect_helper(struct transport *transport)
return 0;
}
static int release_helper(struct transport *transport)
{
disconnect_helper(transport);
free(transport->data);
return 0;
}
static int fetch_with_fetch(struct transport *transport,
int nr_heads, const struct ref **to_fetch)
{
@ -163,6 +170,6 @@ int transport_helper_init(struct transport *transport, const char *name)
transport->data = data;
transport->get_refs_list = get_refs_list;
transport->fetch = fetch;
transport->disconnect = disconnect_helper;
transport->disconnect = release_helper;
return 0;
}