git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Hommey <mh@glandium.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] Fix some more memory leaks in http-push.c
Date: Fri, 14 Dec 2007 22:18:00 +0100	[thread overview]
Message-ID: <1197667081-9909-1-git-send-email-mh@glandium.org> (raw)


Signed-off-by: Mike Hommey <mh@glandium.org>
---
 http-push.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/http-push.c b/http-push.c
index fffbe9c..fc60bfd 100644
--- a/http-push.c
+++ b/http-push.c
@@ -925,11 +925,14 @@ static int fetch_index(unsigned char *sha1)
 				     hex);
 		}
 	} else {
+		free(url);
 		return error("Unable to start request");
 	}
 
-	if (has_pack_index(sha1))
+	if (has_pack_index(sha1)) {
+		free(url);
 		return 0;
+	}
 
 	if (push_verbosely)
 		fprintf(stderr, "Getting index for pack %s\n", hex);
@@ -939,9 +942,11 @@ static int fetch_index(unsigned char *sha1)
 	filename = sha1_pack_index_name(sha1);
 	snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
 	indexfile = fopen(tmpfile, "a");
-	if (!indexfile)
+	if (!indexfile) {
+		free(url);
 		return error("Unable to open local file %s for pack index",
 			     tmpfile);
+	}
 
 	slot = get_active_slot();
 	slot->results = &results;
@@ -1135,10 +1140,12 @@ int fetch_ref(char *ref, unsigned char *sha1)
 	curl_easy_setopt(slot->curl, CURLOPT_URL, url);
 	if (start_active_slot(slot)) {
 		run_active_slot(slot);
+		free(url);
 		if (results.curl_result != CURLE_OK)
 			return error("Couldn't get %s for %s\n%s",
 				     url, ref, curl_errorstr);
 	} else {
+		free(url);
 		return error("Unable to start request");
 	}
 
@@ -2107,6 +2114,7 @@ static int remote_exists(const char *path)
 
         if (start_active_slot(slot)) {
 		run_active_slot(slot);
+		free(url);
 		if (results.http_code == 404)
 			return 0;
 		else if (results.curl_result == CURLE_OK)
@@ -2114,6 +2122,7 @@ static int remote_exists(const char *path)
 		else
 			fprintf(stderr, "HEAD HTTP error %ld\n", results.http_code);
 	} else {
+		free(url);
 		fprintf(stderr, "Unable to start HEAD request\n");
 	}
 
-- 
1.5.4.rc0.8.gbf4af-dirty

             reply	other threads:[~2007-12-14 21:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14 21:18 Mike Hommey [this message]
2007-12-14 21:18 ` [PATCH 2/2] Fix random sha1 in error message in http-fetch and http-push Mike Hommey
2007-12-14 22:17   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1197667081-9909-1-git-send-email-mh@glandium.org \
    --to=mh@glandium.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).