Skip to content

Commit

Permalink
Fix memory leak in helper method for disconnect
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
iabervon authored and gitster committed Nov 18, 2009
1 parent cd0f8e6 commit f2a3715
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

0 comments on commit f2a3715

Please sign in to comment.