Thread (14 messages) flat view 14 messages, 2 authors, 2016-06-15
STALE3738d

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

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:58:52
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help