threads / patch / 5121

patchFix crash when GIT_DIR is invalid

Subject: [PATCH] Fix crash when GIT_DIR is invalid

## tl;dr

3 messages between Aug 4, 2006 and Aug 4, 2006. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Johannes Schindelin· Aug 4, 2006, 15:46 UTC · lore
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(-)
Show changes to setup.c +1 −1
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· Aug 4, 2006, 18:56 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Fix crash when GIT_DIR is invalid

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· Aug 4, 2006, 22:42 UTC · re: Junio C Hamano · lore

Re: [PATCH] Fix crash when GIT_DIR is invalid

Hi,
On Fri, 4 Aug 2006, Junio C Hamano wrote:
Show 8 quoted lines
> 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" --

← back to recent threads