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

Re: Memory leak in ldap_first/next_attribute (ITS#1225)



Section 3 man pages are horriblely out of date.  Use the
latest IETF LDAP C API draft for documentation.  A
copy is available in doc/drafts.

At 12:31 AM 7/9/2001, johan.andersson@appgate.com wrote:
>Full_Name: Johan Andersson
>Version: 2.0.11
>OS: HPUX
>URL: ftp://ftp.openldap.org/incoming/
>Submission from: (NULL) (193.12.107.226)
>
>
>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;
>        attr = ldap_next_attribute(ldap,entry,ber),i++) { ..... }
>
>The memory that 'attr' points to is leaked.
>
>The docs (on your website: 
>   http://www.openldap.org/software/man.cgi?query=ldap_first_attribute&sektion=3&apropos=0&manpath=OpenLDAP+2.0-Release
>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?