Skip to content
/ git Public
forked from git/git

Commit

Permalink
Call git_pathdup() rather than xstrdup(git_path("..."))
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ramsay Jones authored and gitster committed Sep 4, 2012
1 parent 5c44252 commit d292bfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ static int check_ancestors(const char *prefix)
*/
static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
{
char *filename = xstrdup(git_path("BISECT_ANCESTORS_OK"));
char *filename = git_pathdup("BISECT_ANCESTORS_OK");
struct stat st;
int fd;

Expand Down
3 changes: 2 additions & 1 deletion builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d292bfa

Please sign in to comment.