the malloc one was reported to Android (as
https://android-review.googlesource.com/c/platform/bionic/+/2856549)
by wuhaitao3 <wuhait...@xiaomi.corp-partner.google.com>; Chris Ferris
<cfer...@google.com> then spotted the goto nospc one.

the other function in the file looks fine.
diff --git a/lib/libc/net/sethostent.c b/lib/libc/net/sethostent.c
index b5f7ac8f2058..1029b3308c93 100644
--- a/lib/libc/net/sethostent.c
+++ b/lib/libc/net/sethostent.c
@@ -172,6 +172,7 @@ _hf_gethtbyname2(const char *name, int af, struct 
getnamaddr *info)
 
        if ((ptr = buf = malloc(len = info->buflen)) == NULL) {
                *info->he = NETDB_INTERNAL;
+               endhostent_r(&hf);
                return NULL;
        }
 
@@ -252,6 +253,7 @@ _hf_gethtbyname2(const char *name, int af, struct 
getnamaddr *info)
        return hp;
 nospc:
        *info->he = NETDB_INTERNAL;
+       endhostent_r(&hf);
        free(buf);
        errno = ENOSPC;
        return NULL;

Reply via email to