[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Memory leak with ldap_first_attribute()/ldap_next_attribute()?



You need to do a ldap_memfree on each attribute returned by
ldap_first_attribute or ldap_next_attribute
 
-Steve

>>> Bertrand Croq <bcroq@virtual-net.fr> 04-Oct-00 11:06:48 AM >>>
Hi,
  after some hours of debugging, I have been able to write a simple code
that produces memory leaks on my system (OpenLDAP 2.0.4 on Linux Debian
2.2 (x86)):

{
[... ldap_search() ...]
for (a=ldap_first_attribute(ld, e, &ber);
      a!=NULL;
      a=ldap_next_attribute(ld, e, ber)) {
  /* nothing in the body */
}
if (ber)
  ber_free(ber,0);
}

  When I comment out this loop or when ldap_next_attribute() is not
called (when there is no attribute), I don't get any memory leak... This
looks like a problem already posted to this mailing list ("Possible
memory leak in libldap.a/liblber.a" by Ashley Neal Hornbeck on 21 Jan
1999). Does anybody knows what/where the problem can be?

Thanks.
--
Bertrand Croq - VIRTUAL NET (http://www.virtual-net.fr)
80, avenue des Buttes de Coesmes - 35700 RENNES
tel: +33 2 23 21 06 30 - fax: +33 2 99 38 16 85