summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-10-13 21:00:45 +0200
committernulltoken <emeric.fermas@gmail.com>2012-10-15 20:41:43 +0200
commit68206c54bf98f36725d21e7f7efee9f3af68d259 (patch)
tree8c8acd9fa3a5de6ecc051014ecb7c2dc81b7b04a /src
parentfa5d94a0d4d9bbdd167443f052ad4f1f11541aae (diff)
downloadlibgit2-68206c54bf98f36725d21e7f7efee9f3af68d259.tar.gz
test: fix some memory leaks
Diffstat (limited to 'src')
-rw-r--r--src/fetch.c12
-rw-r--r--src/transports/http.c16
2 files changed, 19 insertions, 9 deletions
diff --git a/src/fetch.c b/src/fetch.c
index f9cc8aae1..737a1b4cb 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -58,10 +58,11 @@ static int filter_wants(git_remote *remote)
{
struct filter_payload p;
git_refspec tagspec;
+ int error = -1;
git_vector_clear(&remote->refs);
if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0)
- return -1;
+ return error;
/*
* The fetch refspec can be NULL, and what this means is that the
@@ -75,9 +76,14 @@ static int filter_wants(git_remote *remote)
p.remote = remote;
if (git_repository_odb__weakptr(&p.odb, remote->repo) < 0)
- return -1;
+ goto cleanup;
+
+ error = git_remote_ls(remote, filter_ref__cb, &p);
+
+cleanup:
+ git_refspec__free(&tagspec);
- return git_remote_ls(remote, filter_ref__cb, &p);
+ return error;
}
/* Wait until we get an ack from the */
diff --git a/src/transports/http.c b/src/transports/http.c
index 7b77c925c..93dd0c326 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -93,6 +93,7 @@ static int send_request(transport_http *t, const char *service, void *data, ssiz
#ifndef GIT_WINHTTP
git_buf request = GIT_BUF_INIT;
const char *verb;
+ int error = -1;
verb = ls ? "GET" : "POST";
/* Generate and send the HTTP request */
@@ -102,17 +103,20 @@ static int send_request(transport_http *t, const char *service, void *data, ssiz
}
- if (gitno_send((git_transport *) t, request.ptr, request.size, 0) < 0) {
- git_buf_free(&request);
- return -1;
- }
+ if (gitno_send((git_transport *) t, request.ptr, request.size, 0) < 0)
+ goto cleanup;
if (content_length) {
if (gitno_send((git_transport *) t, data, content_length, 0) < 0)
- return -1;
+ goto cleanup;
}
- return 0;
+ error = 0;
+
+cleanup:
+ git_buf_free(&request);
+ return error;
+
#else
wchar_t *verb;
wchar_t url[GIT_WIN_PATH], ct[GIT_WIN_PATH];