I looked at the Heimdal source, and apparently it has this issue too. Didn't run any tests to verify this though.
I looked at BIND, and indeed res_ndestroy() is defined in the resolv.h header file, but not exported. However, while perusing the source, I noticed if res_ninit() is called more than once on the same res_state structure it will call res_ndestroy() to free up the old memory. Basically, res_ninit() sets the RES_INIT bit. Before doing anything, it also checks that bit, and, if set, calls res_ndestroy(). Res_ndestroy()then unsets that bit. Knowing this, minimizing the memory leak should be really simple. The res_state structure needs to be moved inside the krb5_context. The call to res_ninit() doesn't need to move, but it needs to use the res_state stored in the krb5_context. (Basically, it needs to use the same res_state structure each time.) Note a memory leak should still exist if you constantly create krb5_contexts as Chet's program does. However, Chet's program is inefficient, and you should really never need more than one krb5_context per thread/program. ________________________________________________ Kerberos mailing list [email protected] https://mailman.mit.edu/mailman/listinfo/kerberos
