"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Tracey Emery <tracey@openbsd.org>
Subject:
Re: gotweb: return error instead of NULL
To:
Martin Vahlensieck <openbsd@academicsolutions.ch>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 29 May 2020 07:47:57 -0600

Download raw body.

Thread
On Fri, May 29, 2020 at 07:38:28AM -0600, Tracey Emery wrote:
> On Fri, May 29, 2020 at 01:49:42PM +0200, Martin Vahlensieck wrote:
> > Hi
> > 
> > It looks wrong to return NULL here. First error is set and not used, and
> > second *gw_dir (which is set to NULL) is dereferenced by the next
> > function without checking for NULL.
> > 
> > Best,
> > 
> > Martin
> > 
> > diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
> > index ecbcccb4..1bfc5141 100644
> > --- a/gotweb/gotweb.c
> > +++ b/gotweb/gotweb.c
> > @@ -2099,7 +2099,7 @@ gw_init_gw_dir(struct gw_dir **gw_dir, const char *dir)
> >  		error = got_error_from_errno("asprintf");
> >  		free(*gw_dir);
> >  		*gw_dir = NULL;
> > -		return NULL;
> > +		return error;
> 
> Yes, this is correct.
> Thank you.
> 
> >  	}
> >  
> >  	return NULL;
> 
> -- 
> 
> Tracey Emery

committed. thanks!

-- 

Tracey Emery