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

[PATCH 2/2] cmd_clone: make sure repo is allocated on the heap and free it

From
Carlos Martín Nieto <cmn@elego.de>
Date
Mar 31, 2011, 15:10 UTC
Message-ID
<1301584242-3193-2-git-send-email-cmn@elego.de>
In-Reply-To
<1301584242-3193-1-git-send-email-cmn@elego.de>

Make sure that the buffer repo points to is in the heap and free it afterwards.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
---
 builtin/clone.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index fe0408c..697b1bf 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -415,7 +415,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	else if (!strchr(repo_name, ':'))
 		die("repository '%s' does not exist", repo_name);
 	else
-		repo = repo_name;
+		repo = xstrdup(repo_name);
 	is_local = path && !is_bundle;
 	if (is_local && option_depth)
 		warning("--depth is ignored in local clones; use file:// instead.");
@@ -667,6 +667,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	free(dir);
 	free(path);
+	free(repo);
 	strbuf_release(&reflog_msg);
 	strbuf_release(&branch_top);
 	strbuf_release(&key);
-- 
1.7.4.1
Previous: Carlos Martín Nieto
Message 6 of 6 in “cmd_clone: free dir and path buffers”
  1. 1/2 cmd_clone: free dir and path buffersCarlos Martín Nieto, Mar 31, 2011
  2. 2/2 cmd_clone: make sure repo is allocated on the stack and free itCarlos Martín Nieto, Mar 31, 2011
  3. John SzakmeisterMar 31, 2011
  4. Carlos Martín NietoMar 31, 2011
  5. 1/2 cmd_clone: free dir and path buffersCarlos Martín Nieto, Mar 31, 2011
  6. 2/2 cmd_clone: make sure repo is allocated on the heap and free itCarlos Martín Nieto, Mar 31, 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.