1
0
mirror of https://github.com/git/git.git synced 2024-11-18 17:13:55 +01:00

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>
This commit is contained in:
Michael Haggerty 2012-04-27 00:26:59 +02:00 committed by Junio C Hamano
parent 989c0e5d02
commit 144e709004

@ -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);
}
/*