File nss-dns-memleak-2.patch of Package glibc.2646
Index: glibc-2.19/resolv/nss_dns/dns-host.c
===================================================================
--- glibc-2.19.orig/resolv/nss_dns/dns-host.c
+++ glibc-2.19/resolv/nss_dns/dns-host.c
@@ -315,7 +315,11 @@ _nss_dns_gethostbyname4_r (const char *n
int n = __libc_res_nsearch (&_res, name, C_IN, T_UNSPEC,
host_buffer.buf->buf, 2048, &host_buffer.ptr,
&ans2p, &nans2p, &resplen2, &ans2p_malloced);
- if (n < 0)
+ if (n >= 0)
+ status = gaih_getanswer(host_buffer.buf, n, (const querybuf *) ans2p,
+ resplen2, name, pat, buffer, buflen,
+ errnop, herrnop, ttlp);
+ else
{
switch (errno)
{
@@ -342,17 +346,8 @@ _nss_dns_gethostbyname4_r (const char *n
*errnop = EAGAIN;
else
__set_errno (olderr);
-
- if (host_buffer.buf != orig_host_buffer)
- free (host_buffer.buf);
-
- return status;
}
- status = gaih_getanswer(host_buffer.buf, n, (const querybuf *) ans2p,
- resplen2, name, pat, buffer, buflen,
- errnop, herrnop, ttlp);
-
/* Check whether ans2p was separately allocated. */
if (ans2p_malloced)
free (ans2p);