git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Chris Wilson <cwilson@vigilantsw.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] fetch: plug two leaks on error exit in store_updated_refs
Date: Fri, 07 Oct 2011 08:13:59 +0200	[thread overview]
Message-ID: <4E8E98A7.8010008@lsrfire.ath.cx> (raw)
In-Reply-To: <20111007014136.GB10839@localhost>

Close FETCH_HEAD and release the string url even if we have to leave the
function store_updated_refs() early.

Reported-by: Chris Wilson <cwilson@vigilantsw.com>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 builtin/fetch.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 7a4e41c..79db796 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -379,8 +379,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 		url = xstrdup("foreign");
 
 	rm = ref_map;
-	if (check_everything_connected(iterate_ref_map, 0, &rm))
-		return error(_("%s did not send all necessary objects\n"), url);
+	if (check_everything_connected(iterate_ref_map, 0, &rm)) {
+		error(_("%s did not send all necessary objects\n"), url);
+		free(url);
+		fclose(fp);
+		return -1;
+	}
 
 	for (rm = ref_map; rm; rm = rm->next) {
 		struct ref *ref = NULL;
-- 
1.7.7

  reply	other threads:[~2011-10-07  6:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07  1:41 Fix another file leak Chris Wilson
2011-10-07  6:13 ` René Scharfe [this message]
2011-10-07  6:49   ` [PATCH] fetch: plug two leaks on error exit in store_updated_refs Tay Ray Chuan
2011-10-07  6:59     ` René Scharfe
2011-10-07  7:40       ` [PATCH v2] " Tay Ray Chuan

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=4E8E98A7.8010008@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=cwilson@vigilantsw.com \
    --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).