[24474] in Kerberos
Re: Memory Leak problems with krb5_get_init_creds_password?
daemon@ATHENA.MIT.EDU (brian.joh@comcast.net)
Thu Aug 18 16:28:24 2005
From: brian.joh@comcast.net
Date: 18 Aug 2005 13:22:29 -0700
Message-ID: <1124396549.360322.57980@g14g2000cwa.googlegroups.com>
To: kerberos@mit.edu
Errors-To: kerberos-bounces@mit.edu
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 Kerberos@mit.edu
https://mailman.mit.edu/mailman/listinfo/kerberos