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>
This commit is contained in:
committed by
Junio C Hamano
parent
5c44252e13
commit
d292bfaf35
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user