Hi. I think I may have found a memory leak’s cause in the LDAP routines.
 
The ldap_first_entry routine is reusing the variable ‘result’, which was previously assigned on ldap_search_st, so any of the ldap_msgfree later calls will not pass the original value, as it should.
 
If this is the problem, using a second (LDAPMessage *) variable for the entry-retrieving calls, should do it.
 
 
Just as an example, check this code fragment:
 
if ((result = ldap_first_entry(ld_inst, result)) == NULL) {
  ldap_msgfree(result);
  return 0;
 }
It is wrong, because you are always passing NULL to ldap_msgfree instead of the original value returned from ldap_first_entry
 
It should be:
 
if ((another_ptLDAPMessage_variable = ldap_first_entry(ld_inst, result)) == NULL) {
  ldap_msgfree(result);
  return 0;
 }
 
 
Hope this helps,
---
Juan R. Marchionatto
System Engineer
RR Enterprises

Reply via email to