diff options
author | Matthias Lederhofer <matled@gmx.net> | 2007-06-06 23:29:59 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-06-06 16:07:53 -0700 |
commit | f4f51add2712293b7bc9e7aaebf6a589bb37c7c7 (patch) | |
tree | cb05aa5300e48e16ed7f84f92b39473e38a1e5d3 /setup.c | |
parent | 3ae4a867d37237e8f8156be1409a4a992bd37fb0 (diff) | |
download | git-f4f51add2712293b7bc9e7aaebf6a589bb37c7c7.tar.gz git-f4f51add2712293b7bc9e7aaebf6a589bb37c7c7.tar.xz |
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 <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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; |