[773] in Kerberos-V5-bugs
Re: memory leak in ktf_remove.c
daemon@ATHENA.MIT.EDU (Theodore Ts'o)
Thu Sep 22 22:17:58 1994
Date: Thu, 22 Sep 1994 22:17:53 +0500
From: Theodore Ts'o <tytso@MIT.EDU>
To: Bill Sommerfeld <sommerfeld@apollo.hp.com>
Cc: krb5-bugs@MIT.EDU
In-Reply-To: [677]
Date: Wed, 24 Aug 1994 16:34:26 -0400
From: Bill Sommerfeld <sommerfeld@apollo.hp.com>
There is a small memory leak in lib/krb5/keytab/file/ktf_remove.c.
For reasons I don't fully understand, most of the "destructor"
functions in krb5 only free the contents of structures and don't
actually free the top-level structures themselves.
Fixed in our sources. Thanks for reporting it!
What the "destructor" functions in krb5 do vary from destructor to
destructor. In many cases, there will be a free_foo and a free_foo_cnt,
where the first frees the top-level structure, and the second one
doesn't.
Fundamentally, what's going on here is that we don't have a coherent
allocation/deallocation convention. The reason why krb5_kt_free_entry()
doesn't free the top level structure is because the user-visible
krb5_kt_get_entry() doesn't allocate the top level structure.
Unfortunately, krb5_ktfileint_read_entry() does allocate the top-level
structure, and the resulting impedence match causes the inefficiency and
confusion.
I've dealt with at least part of this problem by redoing the internal
read_entry so that it doesn't allocate a top-level structure, but
instead fills in a passed in structure. This doesn't address the
overall Krb5 API question, though, which is still confusing in this
regard.
- Ted