]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Call git_pathdup() rather than xstrdup(git_path("..."))
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Tue, 4 Sep 2012 17:30:21 +0000 (18:30 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Sep 2012 20:34:46 +0000 (13:34 -0700)
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>
bisect.c
builtin/add.c

index 48acf73391271c1d9061b178a53653357f07f391..1aad49b1a642a308f449001960958ccab79347d1 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -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;
 
index 89dce56a240d69ccb224590bf134c9656d8a0522..2fc267742239c6360c4a38cab7a0277d3407bac2 100644 (file)
@@ -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;
 }