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>
Daniel Barkalow committed
Nov 18, 2009 at 02:42 UTC
f2a37151d4624906e34a9bcafb2ad79d0e8cb7ec
1 file changed
+8
-1
transport-helper.c
+8
-1
@@ -67,6 +67,13 @@ static int disconnect_helper(struct transport *transport)
67
return 0;
68
}
69
70
+static int release_helper(struct transport *transport)
71
+{
72
+ disconnect_helper(transport);
73
+ free(transport->data);
74
+ return 0;
75
+}
76
+
77
static int fetch_with_fetch(struct transport *transport,
78
int nr_heads, const struct ref **to_fetch)
79
{
@@ -163,6 +170,6 @@ int transport_helper_init(struct transport *transport, const char *name)
170
transport->data = data;
171
transport->get_refs_list = get_refs_list;
172
transport->fetch = fetch;
166
- transport->disconnect = disconnect_helper;
173
+ transport->disconnect = release_helper;
174
return 0;
175
}