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

[PATCH 2/2] remote: fix trivial memory leak

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Sep 21, 2013, 14:09 UTC
Message-ID
<1379772563-11000-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1379772563-11000-1-git-send-email-felipe.contreras@gmail.com>

There's no need to set the default remote name beforehand, only to be overridden later on, and causing a memory leak, we can do it after the configuration has been handled.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 remote.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/remote.c b/remote.c
index efcba93..654e7f5 100644
--- a/remote.c
+++ b/remote.c
@@ -480,7 +480,6 @@ static void read_config(void)
 	int flag;
 	if (default_remote_name) /* did this already */
 		return;
-	default_remote_name = xstrdup("origin");
 	current_branch = NULL;
 	head_ref = resolve_ref_unsafe("HEAD", sha1, 0, &flag);
 	if (head_ref && (flag & REF_ISSYMREF) &&
@@ -489,6 +488,8 @@ static void read_config(void)
 			make_branch(head_ref + strlen("refs/heads/"), 0);
 	}
 	git_config(handle_config, NULL);
+	if (!default_remote_name)
+		default_remote_name = xstrdup("origin");
 	alias_all_urls();
 }
 
-- 
1.8.4.2.gac946cf.dirty
Previous: Felipe ContrerasNext: Jeff King
Message 13 of 15 in “fetch: trivial fixes”
  1. 0/2 fetch: trivial fixesFelipe Contreras, Sep 21, 2013
  2. 1/2 fetch: add missing documentationFelipe Contreras, Sep 21, 2013
  3. Jeff KingSep 24, 2013
  4. Felipe ContrerasSep 24, 2013
  5. Jeff KingSep 24, 2013
  6. Felipe ContrerasSep 24, 2013
  7. Jeff KingSep 24, 2013
  8. Felipe ContrerasSep 24, 2013
  9. Jeff KingSep 24, 2013
  10. Felipe ContrerasSep 24, 2013
  11. Jeff KingSep 24, 2013
  12. Felipe ContrerasSep 24, 2013
  13. 2/2 remote: fix trivial memory leakFelipe Contreras, Sep 21, 2013
  14. Jeff KingSep 24, 2013
  15. Junio C HamanoOct 15, 2013

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.