diff options
author | Ramsay Jones <ramsay@ramsay1.demon.co.uk> | 2012-09-04 18:30:21 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-04 13:34:46 -0700 |
commit | d292bfaf356338b41e14e40ce4dbd6b9c8d600ec (patch) | |
tree | de4467f56e9d534169cd05b6a25e4a8e6ca60a73 /builtin/add.c | |
parent | 5c44252e13db2324d7c79d2b498886a925055111 (diff) | |
download | git-d292bfaf356338b41e14e40ce4dbd6b9c8d600ec.tar.gz |
Call git_pathdup() rather than xstrdup(git_path("..."))
In addition to updating the two xstrdup(git_path("...")) call sites
with git_pathdup(), we also fix a memory leak by freeing the memory
allocated to the ADD_EDIT.patch 'file' in the edit_patch() function.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r-- | builtin/add.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/add.c b/builtin/add.c index 89dce56a24..2fc2677422 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -260,7 +260,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch) static int edit_patch(int argc, const char **argv, const char *prefix) { - char *file = xstrdup(git_path("ADD_EDIT.patch")); + char *file = git_pathdup("ADD_EDIT.patch"); const char *apply_argv[] = { "apply", "--recount", "--cached", NULL, NULL }; struct child_process child; @@ -303,6 +303,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix) die (_("Could not apply '%s'"), file); unlink(file); + free(file); return 0; } |