git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fetch: plug two leaks on error exit in store_updated_refs

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Oct 7, 2011, 06:13 UTC
Message-ID
<4E8E98A7.8010008@lsrfire.ath.cx>
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
Previous: Chris WilsonNext: Tay Ray Chuan
Message 2 of 5 in “Fix another file leak”
  1. Chris WilsonOct 7, 2011
  2. fetch: plug two leaks on error exit in store_updated_refsRené Scharfe, Oct 7, 2011
  3. Tay Ray ChuanOct 7, 2011
  4. René ScharfeOct 7, 2011
  5. fetch: plug two leaks on error exit in store_updated_refsTay Ray Chuan, Oct 7, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.