mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
netutils/thttpd: Apply the same check to related allocation sites
Extend the allocation-failure check to httpd_strdup(), the thttpd-local wrapper that has the same failure contract as strdup(). This is logically separable from the direct strdup()/asprintf() fixes: it prevents using hs->hostname before checking whether the wrapped string allocation succeeded, and releases the partially allocated server state on failure. The scope intentionally does not extend to malloc(), calloc(), or other raw allocators because #1727 specifically calls out strdup()/asprintf(), and covering all allocation APIs would make this PR much broader. Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
This commit is contained in:
parent
c44f9a0556
commit
8568013436
1 changed files with 3 additions and 2 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue