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

Re: ldap_msgfree() when ldap_search_s() failed



> > I'm using openldap 2.2.13 and have a question about ldap_msgfree().
> > After executing ldap_search_s() or ldap_result(), it seems to have to
> > execute ldap_msgfree() regardless of the success or failure. Is it
> > right?

Can you be more specific about "success or failure"?

If I understand rightly, ldap_result() sets a pointer to an LDAPMessage 
structure, in the event that a message is available. If it does, you have to 
free it. This will be the case even if your search returns zero entries, for 
instance (which is a "successful" search).

However, if ldap_result() itself fails (returning -1 for error or 0 for 
timeout waiting for a result), then I don't think that anything is allocated, 
so there's nothing to free.

So, can you give an example of a code snippet which is not behaving as you 
expect, explaining what actually happens, and what you think should happen 
instead?