summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-09-19 00:49:42 -0400
committerJunio C Hamano <gitster@pobox.com>2007-09-19 03:22:31 -0700
commitf4e95765b042f3e31a8902e78a5101768b33e445 (patch)
tree1bd7da85c736adede0cd986799670ee9f8efc168 /transport.c
parent50ab5fd3fc16fbe01170059977533fa2c7c4d448 (diff)
downloadgit-f4e95765b042f3e31a8902e78a5101768b33e445.tar.gz
Fix memory leaks when disconnecting transport instances
Most transport implementations tend to allocate a data buffer in the struct transport instance during transport_get() so we need to free that data buffer when we disconnect it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/transport.c b/transport.c
index a1d0a3c899..4f9cddc308 100644
--- a/transport.c
+++ b/transport.c
@@ -236,6 +236,7 @@ static int close_bundle(struct transport *transport)
struct bundle_transport_data *data = transport->data;
if (data->fd > 0)
close(data->fd);
+ free(data);
return 0;
}
@@ -372,6 +373,12 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
return !!err;
}
+static int disconnect_git(struct transport *transport)
+{
+ free(transport->data);
+ return 0;
+}
+
static int is_local(const char *url)
{
const char *colon = strchr(url, ':');
@@ -419,6 +426,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
ret->get_refs_list = get_refs_via_connect;
ret->fetch = fetch_refs_via_pack;
ret->push = git_transport_push;
+ ret->disconnect = disconnect_git;
data->thin = 1;
data->uploadpack = "git-upload-pack";