Closing the stream when the function returns
Test: build
Signed-off-by: wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>
Change-Id: I85a7935d911bf19c85c51a4c52a43e2efed34929
diff --git a/libc/dns/net/sethostent.c b/libc/dns/net/sethostent.c
index 483105a..5c4bdb5 100644
--- a/libc/dns/net/sethostent.c
+++ b/libc/dns/net/sethostent.c
@@ -157,6 +157,7 @@
if ((ptr = buf = malloc(len = info->buflen)) == NULL) {
*info->he = NETDB_INTERNAL;
+ endhostent_r(&hf);
return NULL;
}
@@ -241,6 +242,7 @@
return hp;
nospc:
*info->he = NETDB_INTERNAL;
+ endhostent_r(&hf);
free(buf);
errno = ENOSPC;
return NULL;