summaryrefslogtreecommitdiff
path: root/bisect.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-04-27 00:26:59 +0200
committerJunio C Hamano <gitster@pobox.com>2012-05-03 13:15:35 -0700
commit144e7090045a703c8f5d140474f202ba4f38ac9a (patch)
treec14d77bf2b2c6d5e5c24035e47887baeb39e33d9 /bisect.c
parent989c0e5d02b1844b44e5ea2ff61a2cbd2f054a25 (diff)
downloadgit-144e7090045a703c8f5d140474f202ba4f38ac9a.tar.gz
bisect: copy filename string obtained from git_path()
Prevent the string from being overwritten by other callers of git_path() and friends before we are done using it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bisect.c')
-rw-r--r--bisect.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bisect.c b/bisect.c
index 6e186e29cc..48acf73391 100644
--- 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)
{
- const char *filename = git_path("BISECT_ANCESTORS_OK");
+ char *filename = xstrdup(git_path("BISECT_ANCESTORS_OK"));
struct stat st;
int fd;
@@ -842,11 +842,11 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
/* Check if file BISECT_ANCESTORS_OK exists. */
if (!stat(filename, &st) && S_ISREG(st.st_mode))
- return;
+ goto done;
/* Bisecting with no good rev is ok. */
if (good_revs.nr == 0)
- return;
+ goto done;
/* Check if all good revs are ancestor of the bad rev. */
if (check_ancestors(prefix))
@@ -859,6 +859,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
filename, strerror(errno));
else
close(fd);
+ done:
+ free(filename);
}
/*