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

Re: Memory leaks using ldap_first_attribute(), ldap_next_attribute(), and ber_free()



Hi!


2.0.17 or 2.2.17?

If it is 2.0.17, OpenLDAP 2.0.x has been deprecated for a long time now, and the last release of OL 2.0 line as I recall was OpenLDAP 2.0.27. In that case, you should really examine upgrading to the 2.2 library set.
	
	Yep.. it's OpenLDAP 2.0.27. 'cause I'm using RH9 and I haven't
updated it.

First of all, about the second argument of ber_free().
ldap_{first,next}_atribute manpage (at
http://www.openldap.org/software/man.cgi) says:
"When calling ber_free(3) in this instance, be sure the second argument
is 0."
But ber_free() manpage says:
"If freebuf is zero, the internal buffer is not freed"
A little bit confusing, don't you think so?


Hm, I don't see it that way...

This reads to me as:

If you are using ldap_{first,next}_attribute, you don't want to execute the ber_free_buf( ber ) bit in ber_free, but you do want to execute ber_memfree_x( (char *) ber, ber->ber_memctx).

Here's the ber_free code in 2.2.18:

void
ber_free( BerElement *ber, int freebuf )
{
#ifdef LDAP_MEMORY_DEBUG
   assert( ber != NULL );
#endif

   if( ber == NULL ) {
       return;
   }

   if( freebuf ) ber_free_buf( ber );

   ber_memfree_x( (char *) ber, ber->ber_memctx );
}

	Hmmm... I see...

Unfortunately, I don't have anything to suggest on the rest of your code.

Ok, so I gonna update libldap up to 2.2.18 and let's see what happens :) Thanks a lot.

--

[]'s
Lucas Brasilino
brasilino@recife.pe.gov.br
http://www.recife.pe.gov.br
Emprel -	Empresa Municipal de Informatica (pt_BR)
		Municipal Computing Enterprise (en_US)
Recife - Pernambuco - Brasil
Fone: +55-81-32327078