{"thread":{"id":"31432","subject":"[PATCH 4/5] Call git_pathdup() rather than xstrdup(git_path(\"...\"))","startedAt":"2012-09-04T17:30:21Z","lastAt":"2012-09-04T17:30:21Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"198329","messageId":"50463AAD.7060107@ramsay1.demon.co.uk","threadId":"31432","inReplyTo":null,"subject":"[PATCH 4/5] Call git_pathdup() rather than xstrdup(git_path(\"...\"))","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-09-04T17:30:21Z","receivedAt":"2012-09-04T17:30:21Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIn addition to updating the two xstrdup(git_path(\"...\")) call sites\nwith git_pathdup(), we also fix a memory leak by freeing the memory\nallocated to the ADD_EDIT.patch 'file' in the edit_patch() function.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n bisect.c      | 2 +-\n builtin/add.c | 3 ++-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 48acf73..1aad49b 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -833,7 +833,7 @@ static int check_ancestors(const char *prefix)\n  */\n static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)\n {\n-\tchar *filename = xstrdup(git_path(\"BISECT_ANCESTORS_OK\"));\n+\tchar *filename = git_pathdup(\"BISECT_ANCESTORS_OK\");\n \tstruct stat st;\n \tint fd;\n \ndiff --git a/builtin/add.c b/builtin/add.c\nindex 89dce56..2fc2677 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -260,7 +260,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)\n \n static int edit_patch(int argc, const char **argv, const char *prefix)\n {\n-\tchar *file = xstrdup(git_path(\"ADD_EDIT.patch\"));\n+\tchar *file = git_pathdup(\"ADD_EDIT.patch\");\n \tconst char *apply_argv[] = { \"apply\", \"--recount\", \"--cached\",\n \t\tNULL, NULL };\n \tstruct child_process child;\n@@ -303,6 +303,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \t\tdie (_(\"Could not apply '%s'\"), file);\n \n \tunlink(file);\n+\tfree(file);\n \treturn 0;\n }\n \n-- \n1.7.12\n"}]}