diff --git a/netutils/thttpd/libhttpd.c b/netutils/thttpd/libhttpd.c index 1a7d46c13..8be1c6ec9 100644 --- a/netutils/thttpd/libhttpd.c +++ b/netutils/thttpd/libhttpd.c @@ -2163,14 +2163,15 @@ FAR httpd_server *httpd_initialize(FAR httpd_sockaddr *sa) #else hs->hostname = httpd_strdup(httpd_ntoa(sa)); #endif - ninfo("hostname: %s\n", hs->hostname); - if (!hs->hostname) { nerr("ERROR: out of memory copying hostname\n"); + free_httpd_server(hs); return NULL; } + ninfo("hostname: %s\n", hs->hostname); + hs->cgi_count = 0; /* Initialize listen sockets */