This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Memory leak in the resolver (threads)
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 21 Feb 2003 14:37:59 -0500
- Subject: Memory leak in the resolver (threads)
I received an interesting bug report about a small memory leak in the
resolver. Suppose that you have an application which creates a new thread
every time it wants to do a DNS lookup. In the course of the request, some
memory is allocated, in __libc_res_nsend:
for (ns = 0; ns < EXT(statp).nscount; ns++) {
n = map[ns];
if (EXT(statp).nsaddrs[n] == NULL)
EXT(statp).nsaddrs[n] =
malloc(sizeof (struct sockaddr_in6));
if (EXT(statp).nsaddrs[n] != NULL) {
memcpy(EXT(statp).nsaddrs[n],
&statp->nsaddr_list[ns],
sizeof (struct sockaddr_in));
EXT(statp).nssocks[n] = -1;
n++;
}
}
A sockaddr per nameserver. I can't see a logical place to free this
data, so when the thread exits, it is leaked. Does anyone have a suggestion
on how to clean this up?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer