From: Matthias Lederhofer Date: Wed, 6 Jun 2007 21:29:59 +0000 (+0200) Subject: setup_git_directory: fix segfault if repository is found in cwd X-Git-Tag: v1.5.3-rc0~29^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f4f51add2712293b7bc9e7aaebf6a589bb37c7c7;p=git.git setup_git_directory: fix segfault if repository is found in cwd Additionally there was a similar part calling setenv and getenv in the same way which missed a check if getenv succeeded. Signed-off-by: Matthias Lederhofer Signed-off-by: Junio C Hamano --- diff --git a/setup.c b/setup.c index 14a4d955b..dba801265 100644 --- a/setup.c +++ b/setup.c @@ -251,6 +251,9 @@ const char *setup_git_directory_gently(int *nongit_ok) die("Not a git repository"); } setenv(GIT_DIR_ENVIRONMENT, cwd, 1); + gitdirenv = getenv(GIT_DIR_ENVIRONMENT); + if (!gitdirenv) + die("getenv after setenv failed"); } if (PATH_MAX - 40 < strlen(gitdirenv)) { @@ -290,6 +293,8 @@ const char *setup_git_directory_gently(int *nongit_ok) if (gitdirenv[0] != '/') { setenv(GIT_DIR_ENVIRONMENT, gitdir, 1); gitdirenv = getenv(GIT_DIR_ENVIRONMENT); + if (!gitdirenv) + die("getenv after setenv failed"); if (PATH_MAX - 40 < strlen(gitdirenv)) { if (nongit_ok) { *nongit_ok = 1;