[krbdev.mit.edu #1665] memory leak in krb5_{init,free}_context

Ezra Peisach epeisach at MIT.EDU
Tue Jul 15 18:32:44 EDT 2003


Our code base has not changed in a while. I noticed this once...

krb5_init_context does initialize the error tables.

krb5_init_ets does an initiazlie_XXX_error_table() each time.
This calls add_error_table - this adds the error table to the list.

Note - this is with our com_err code.

Note2: nothing has changed in this code since 2001.

Note3: Probably when we modified init_context to initialize the error
tables (which is a good think - the error was introduced)

Now - usually - all our code calls init_context once or twice (i.e. 
the internal gssapi krb5_context, the krb4 one, etc) - so no-one is
hurt.

In the example code - memory will leak.

While in theory - we could add a reference count for each error table,
krb5_free_ets does nothing...

A simple code change would be to lib/krb5/error_tables/init_ets to have
a simple reference count which is incremented when someone calls it - 
and a decrement in free_ets would make sense - then have free_ets
release the error table if the count reaches zero.

	Ezra


More information about the krb5-bugs mailing list