[samba4] Memory leak in LDAP

Karl Melcher kmelcher at gmail.com
Tue Sep 13 19:39:41 GMT 2005


I have tracked a LDAP related memory leak to the data blob of the request 
structure. Upon sending a LDAP request via ldap_request_send, the data blob 
is never freed. When the blob is allocated it is passed a NULL memory 
context, so it is not tied to any other memory that would be freed. 

Additionally, the data pointer in the ldap_request.data structure is being 
incremented in the ldap_send_handler() function in ldap_client.c. Therefore, 
attempting to free it by a direct call to data_blob_free does not work.

Am I missing something in how this memory is to be managed, or is this a 
bug? If it's a bug, then I have identified two possible solutions are:

1. copy the original data blob pointer before it is altered in the 
ldap_send_handler. Then use this in a call to data_blob_free()
2. Pass a memory context to the data blob allocator so it is tied to the 
request and freed when the request is freed.


Karl


More information about the samba-technical mailing list