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

Memory leak in ldap_first/next_attribute (ITS#1225)

Full_Name: Johan Andersson
Version: 2.0.11
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

I am running Purify on a small client program using openLDAP's client library. 
I am iterating over returned attributes in a query with:

  char* attr;
  for ( i = 0, attr = ldap_first_attribute( ldap, entry, &ber);
	attr = ldap_next_attribute(ldap,entry,ber),i++) { ..... }

The memory that 'attr' points to is leaked.

The docs (on your website: 
says the returned 'attr' is to be considered as a static buffer. 

However following the source $/libraries/libldap/getattr.c#77/107
         tag = ber_scanf( ber, "{ax}", &attr ); 

looks like the memory is plainly allocated and just returned. Either the docs
are wrong 
or you forgot to assign the allocated buffer to some 'connection context'
somewhere and 
reuse it. Do you agree?