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

From:
Martin Vahlensieck <openbsd@academicsolutions.ch>
Subject:
gotweb: return error instead of NULL
To:
gameoftrees@openbsd.org
Date:
Fri, 29 May 2020 13:49:42 +0200

Download raw body.

Thread
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;
 	}
 
 	return NULL;