LDB hidden memory leaks

Kamen Mazdrashki kamenim at gmail.com
Sun Jul 4 15:38:51 MDT 2010

Hi guys,

As I wrote in the below mentioned thread, there are few functions in LDB
that are easy to leak memory with at present.

While this behavior is not a problem for utilities that uses LDB like ldbadd
for example,
it is a problem for Samba itself as it is supposed to be working 24/7.
In case of Samba, memory allocated in ldb_context context and not freed
quickly is
 leaked memory as it will go away with LDB connection, i.e. presumably never

I've pushed two approaches to the problem:
1) Introduce new functions and declare old ones as obsolete

Allocate memory in NULL context internally, so we will be able to notice,
when those
functions are used in dangerous manner

branches affect only ldb_msg_canonicalize() function. It is basically the
for ldb_msg_diff() function.

IMO approach 1) is better one as it leaves no doubt of who the owner of the
memory is.
But this approach will change LDB ABI a little, which may be not acceptable
for everyone.
(If I recall correctly, Simo is a strong defender of LDB ABI)

Approach 2) tries to solve the problem without ABI change but I think it
will lead us
(or other LDB users) to the same problem soon or later.

So, what do you think?

Kamen Mazdrashki
Samba Team Developer         http://samba.org
kamen.mazdrashki at postpath.com

More information about the samba-technical mailing list