git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Hommey <mh@glandium.org>
To: git@vger.kernel.org
Subject: [Resend PATCH] Fix some memory leaks in various places
Date: Sat, 26 Jan 2008 11:50:27 +0100	[thread overview]
Message-ID: <1201344627-21609-1-git-send-email-mh@glandium.org> (raw)


Signed-off-by: Mike Hommey <mh@glandium.org>
---

 I think I sent this already last month, but since I see that nowhere on
 next or master, I'm resending, just in case it got lost.

 builtin-init-db.c |    1 +
 http-walker.c     |   10 ++++++++++
 walker.c          |    2 ++
 3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index e1393b8..df61758 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -415,6 +415,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	safe_create_dir(path, 1);
 	strcpy(path+len, "/info");
 	safe_create_dir(path, 1);
+	free(path);
 
 	if (shared_repository) {
 		char buf[10];
diff --git a/http-walker.c b/http-walker.c
index 2c37868..1a02f86 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -231,6 +231,8 @@ static void finish_object_request(struct object_request *obj_req)
 {
 	struct stat st;
 
+	free(obj_req->url);
+
 	fchmod(obj_req->local, 0444);
 	close(obj_req->local); obj_req->local = -1;
 
@@ -897,9 +899,17 @@ static int fetch_ref(struct walker *walker, char *ref, unsigned char *sha1)
 static void cleanup(struct walker *walker)
 {
 	struct walker_data *data = walker->data;
+	struct alt_base *prev_altbase, *altbase = data->alt;
+	while (altbase) {
+		free(altbase->base);
+		prev_altbase = altbase;
+		altbase = altbase->next;
+		free(prev_altbase);
+	}
 	http_cleanup();
 
 	curl_slist_free_all(data->no_pragma_header);
+	free(data);
 }
 
 struct walker *get_http_walker(const char *url)
diff --git a/walker.c b/walker.c
index adc3e80..64fc419 100644
--- a/walker.c
+++ b/walker.c
@@ -299,6 +299,7 @@ int walker_fetch(struct walker *walker, int targets, char **target,
 			goto unlock_and_fail;
 	}
 	free(msg);
+	free(sha1);
 
 	return 0;
 
@@ -306,6 +307,7 @@ unlock_and_fail:
 	for (i = 0; i < targets; i++)
 		if (lock[i])
 			unlock_ref(lock[i]);
+	free(sha1);
 
 	return -1;
 }
-- 
1.5.4.rc3.30.gb084e

             reply	other threads:[~2008-01-26 10:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-26 10:50 Mike Hommey [this message]
2008-01-27  2:18 ` [Resend PATCH] Fix some memory leaks in various places 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=1201344627-21609-1-git-send-email-mh@glandium.org \
    --to=mh@glandium.org \
    --cc=git@vger.kernel.org \
    /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).