{"thread":{"id":"26945","subject":"[PATCH 2/2] cmd_clone: make sure repo is allocated on the stack and free it","startedAt":"2011-03-31T14:18:41Z","lastAt":"2011-03-31T15:10:42Z","messageCount":6,"participants":["Carlos Martín Nieto","John Szakmeister"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"164796","messageId":"1301581122-19947-1-git-send-email-cmn@elego.de","threadId":"26945","inReplyTo":null,"subject":"[PATCH 1/2] cmd_clone: free dir and path buffers","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-03-31T14:18:41Z","receivedAt":"2011-03-31T14:18:41Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"The variables dir and path are always allocated on the stack so it's\nalways safe to free them.\n\nThis memory would be freed by _exit, but it's good form to free memory\nyou've allocated.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n\n This is a split-up version of an earlier patch. It's not a big deal,\nbut I had it in a local branch and I though I'd try to have it merged upstream.\n\n builtin/clone.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 2ee1fa9..fe0408c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -665,6 +665,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\terr = run_command_v_opt(argv_submodule, RUN_GIT_CMD);\n \t}\n \n+\tfree(dir);\n+\tfree(path);\n \tstrbuf_release(&reflog_msg);\n \tstrbuf_release(&branch_top);\n \tstrbuf_release(&key);\n-- \n1.7.4.1\n"},{"id":"164795","messageId":"1301581122-19947-2-git-send-email-cmn@elego.de","threadId":"26945","inReplyTo":"1301581122-19947-1-git-send-email-cmn@elego.de","subject":"[PATCH 2/2] cmd_clone: make sure repo is allocated on the stack and free it","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-03-31T14:18:42Z","receivedAt":"2011-03-31T14:18:42Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"Make sure that the buffer repo points to is in the stack and free it\nafterwards.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n builtin/clone.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex fe0408c..697b1bf 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -415,7 +415,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \telse if (!strchr(repo_name, ':'))\n \t\tdie(\"repository '%s' does not exist\", repo_name);\n \telse\n-\t\trepo = repo_name;\n+\t\trepo = xstrdup(repo_name);\n \tis_local = path && !is_bundle;\n \tif (is_local && option_depth)\n \t\twarning(\"--depth is ignored in local clones; use file:// instead.\");\n@@ -667,6 +667,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \tfree(dir);\n \tfree(path);\n+\tfree(repo);\n \tstrbuf_release(&reflog_msg);\n \tstrbuf_release(&branch_top);\n \tstrbuf_release(&key);\n-- \n1.7.4.1\n"},{"id":"164798","messageId":"AANLkTi=XYv1WFbvHwqvrJDkssKC-zU91Vj4EPbZG6OK2@mail.gmail.com","threadId":"26945","inReplyTo":"1301581122-19947-1-git-send-email-cmn@elego.de","subject":"Re: [PATCH 1/2] cmd_clone: free dir and path buffers","fromName":"John Szakmeister","fromEmail":"john@szakmeister.net","sentAt":"2011-03-31T14:45:07Z","receivedAt":"2011-03-31T14:45:07Z","isPatch":true,"sender":{"key":"john@szakmeister.net","avatar":"https://avatars.githubusercontent.com/u/448087?v=4"},"body":"On Thu, Mar 31, 2011 at 10:18 AM, Carlos Martín Nieto <cmn@elego.de> wrote:\n> The variables dir and path are always allocated on the stack so it's\n> always safe to free them.\n\nI think you mean \"on the heap\". :-)\n\n-John\n"},{"id":"164800","messageId":"1301583996.11592.3.camel@bee.lab.cmartin.tk","threadId":"26945","inReplyTo":"AANLkTi=XYv1WFbvHwqvrJDkssKC-zU91Vj4EPbZG6OK2@mail.gmail.com","subject":"Re: [PATCH 1/2] cmd_clone: free dir and path buffers","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-03-31T15:06:29Z","receivedAt":"2011-03-31T15:06:29Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On jue, 2011-03-31 at 10:45 -0400, John Szakmeister wrote:\n> On Thu, Mar 31, 2011 at 10:18 AM, Carlos Martín Nieto <cmn@elego.de> wrote:\n> > The variables dir and path are always allocated on the stack so it's\n> > always safe to free them.\n> \n> I think you mean \"on the heap\". :-)\n\n Indeed I do \n\n   cmn\n"},{"id":"164801","messageId":"1301584242-3193-1-git-send-email-cmn@elego.de","threadId":"26945","inReplyTo":"1301583996.11592.3.camel@bee.lab.cmartin.tk","subject":"[PATCH 1/2] cmd_clone: free dir and path buffers","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-03-31T15:10:41Z","receivedAt":"2011-03-31T15:10:41Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"The variables dir and path are always allocated on the heap so it's\nalways safe to free them.\n\nThis memory would be freed by _exit, but it's good form to free memory\nyou've allocated.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n\nHopefully this time there are no silly mistakes.\n\n builtin/clone.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 2ee1fa9..fe0408c 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -665,6 +665,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\terr = run_command_v_opt(argv_submodule, RUN_GIT_CMD);\n \t}\n \n+\tfree(dir);\n+\tfree(path);\n \tstrbuf_release(&reflog_msg);\n \tstrbuf_release(&branch_top);\n \tstrbuf_release(&key);\n-- \n1.7.4.1\n"},{"id":"164802","messageId":"1301584242-3193-2-git-send-email-cmn@elego.de","threadId":"26945","inReplyTo":"1301584242-3193-1-git-send-email-cmn@elego.de","subject":"[PATCH 2/2] cmd_clone: make sure repo is allocated on the heap and free it","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-03-31T15:10:42Z","receivedAt":"2011-03-31T15:10:42Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"Make sure that the buffer repo points to is in the heap and free it\nafterwards.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n builtin/clone.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex fe0408c..697b1bf 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -415,7 +415,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \telse if (!strchr(repo_name, ':'))\n \t\tdie(\"repository '%s' does not exist\", repo_name);\n \telse\n-\t\trepo = repo_name;\n+\t\trepo = xstrdup(repo_name);\n \tis_local = path && !is_bundle;\n \tif (is_local && option_depth)\n \t\twarning(\"--depth is ignored in local clones; use file:// instead.\");\n@@ -667,6 +667,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \tfree(dir);\n \tfree(path);\n+\tfree(repo);\n \tstrbuf_release(&reflog_msg);\n \tstrbuf_release(&branch_top);\n \tstrbuf_release(&key);\n-- \n1.7.4.1\n"}]}