res_nsearch leak?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

res_nsearch leak?

Michael B Allen-4

I'm trying to track down a leak in res_nsearch as demonstrated by the
following program:

#include <stdlib.h>
#include <resolv.h>

        unsigned char buf[1024];
        struct __res_state state;
        int len;

        memset(&state, 0, sizeof(state));
        len = res_nsearch(&state, "", 1, 1, buf, sizeof(buf));

        return EXIT_SUCCESS;

==8684== 28 bytes in 1 blocks are definitely lost in loss record 1 of 1
==8684==    at 0x1B905A90: malloc (vg_replace_malloc.c:131)
==8684==    by 0xA3E107: __libc_res_nsend (in /lib/
==8684==    by 0xA3D0F2: __GI___libc_res_nquery (in /lib/
==8684==    by 0xA3D3B7: __libc_res_nquerydomain (in /lib/
==8684==    by 0xA3D91D: __GI___libc_res_nsearch (in /lib/
==8684==    by 0xA3DA99: __GI___res_nsearch (in /lib/
==8684==    by 0x80485E9: main (in /home/miallen/p/c/nsearch)
==8684== LEAK SUMMARY:
==8684==    definitely lost: 28 bytes in 1 blocks.

I've checked 2.5 see no change in the resolve code. I've checked the
latest bind and see res_ndestroy is interesting but glibc doesn't seem
to have it. Can someone tell me where I went wrong?