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

[PATCH 3/9] fetch: Fix minor memory leak

From
AGAndreas Gruenbacher <agruen@suse.de>
Date
Mar 15, 2010, 22:18 UTC
Message-ID
<b7762c1e05412618584e38b868bcc870676f6e62.1268913163.git.agruen@suse.de>
In-Reply-To
<f747d7538f2a2bbdb48c9902298fa87691097eba.1268913163.git.agruen@suse.de>

A temporary struct ref is allocated in store_updated_refs() but not freed.

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
---
 builtin/fetch.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 660af84..957be9f 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -389,9 +389,10 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 				fputc(url[i], fp);
 		fputc('\n', fp);
 
-		if (ref)
+		if (ref) {
 			rc |= update_local_ref(ref, what, note);
-		else
+			free(ref);
+		} else
 			sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
 				TRANSPORT_SUMMARY_WIDTH, *kind ? kind : "branch",
 				 REFCOL_WIDTH, *what ? what : "HEAD");
-- 
1.7.0.2.273.gc2413
Previous: Andreas GruenbacherNext: Andreas Gruenbacher
Message 4 of 14 in “Multiple remotes without conflicts”
  1. 0/9 Multiple remotes without conflictsAndreas Gruenbacher, Mar 18, 2010
  2. 1/9 fetch: Check for a "^{}" suffix with suffixcmp()Andreas Gruenbacher, Mar 13, 2010
  3. 2/9 fetch: Properly initialize refspec on stackAndreas Gruenbacher, Mar 12, 2010
  4. 3/9 fetch: Fix minor memory leakAndreas Gruenbacher, Mar 15, 2010
  5. 4/9 fetch: Move deepening fetch check into builtin/fetch.cAndreas Gruenbacher, Mar 16, 2010
  6. 5/9 fetch: Move loop checking which refs we have alreadyAndreas Gruenbacher, Mar 16, 2010
  7. 6/9 fetch: Check if all objects exist after fetchingAndreas Gruenbacher, Mar 16, 2010
  8. 7/9 fetch: Use the same ref map for all branches and tagsAndreas Gruenbacher, Mar 17, 2010
  9. 8/9 fetch: Don't fetch tags twiceAndreas Gruenbacher, Mar 17, 2010
  10. 9/9 fetch: Make automatic tag following work with arbitrary refspecsAndreas Gruenbacher, Mar 17, 2010
  11. Shawn O. PearceMar 18, 2010
  12. Andreas GruenbacherMar 18, 2010
  13. Shawn O. PearceMar 18, 2010
  14. Andreas GruenbacherMar 18, 2010

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.