# [PATCH] Fix crash when GIT_DIR is invalid

3 messages from 2006-08-04 to 2006-08-04. Participants: Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/5121

## Johannes Schindelin, 2006-08-04 15:46

Subject: [PATCH] Fix crash when GIT_DIR is invalid
Message-ID: <Pine.LNX.4.63.0608041745500.1800@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0608041745500.1800%40wbgn013.biozentrum.uni-wuerzburg.de

```

We used to test if a pointer was NULL, and if it was, try to access it.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index 358e139..2afdba4 100644
--- a/setup.c
+++ b/setup.c
@@ -184,7 +184,7 @@ const char *setup_git_directory_gently(i
 		}
 		return NULL;
 	bad_dir_environ:
-		if (!nongit_ok) {
+		if (nongit_ok) {
 			*nongit_ok = 1;
 			return NULL;
 		}
-- 
1.4.2.rc2.g0bca-dirty

```

## Junio C Hamano, 2006-08-04 18:56

Subject: Re: [PATCH] Fix crash when GIT_DIR is invalid
Message-ID: <7virl8jpnw.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7virl8jpnw.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0608041745500.1800@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>  	bad_dir_environ:
> -		if (!nongit_ok) {
> +		if (nongit_ok) {
>  			*nongit_ok = 1;

*BLUSH*  How could I have missed something like this...

Thanks.

```

## Johannes Schindelin, 2006-08-04 22:42

Subject: Re: [PATCH] Fix crash when GIT_DIR is invalid
Message-ID: <Pine.LNX.4.63.0608050041230.1800@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0608050041230.1800%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7virl8jpnw.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Fri, 4 Aug 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> >  	bad_dir_environ:
> > -		if (!nongit_ok) {
> > +		if (nongit_ok) {
> >  			*nongit_ok = 1;
> 
> *BLUSH*  How could I have missed something like this...

It's too easy. I actually reviewed that patch, saw that I did the same 
(not!), and hit the bug...

Ciao,
Dscho "errare humanum est" --

```
