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

Re: ber_memfree debugging



Julio Sánchez Fernández wrote:
> 
> "Kurt D. Zeilenga" wrote:
> >
> > At 09:39 PM 6/6/99 +0200, Bert Vermeulen wrote:
> 
> > >It's bombing out on me because
> > >ldap_str2attributetype() in libldap frees pointers regardless if they've
> > >been used or not.
> >
> > Before the recent memory allocation changes, this code called
> > free(NULL).  This is a bug.  OpenLDAP should not assume
> > STDC semantics.  I've added asserts specifically to detect
> > such bugs.
> 
> IIRC, it called ldap_memfree, that was NULL-safe.

You are correct.  I should have added the NULL checks when I made
the switch.

> If the free routines are now NULL-unsafe, the code should be fixed.

I'll move the assert(NULL) behind an #ifdef for now.

> Should I do this?

I have code ready to commit.

> On a related topic, Bert has asked me to externalize free_syn, free_at
> and free_oc (whose names would have to be prefixed by ldap_ or something)

Sounds reasonable.  These routines should allow a NULL argument
for consistency.

> so that they can be used from clients.  I see no problem with this, except
> that current code in slapd presumes that once such an entity has been
> passed to at_add, oc_add, etc. it will not be freed since it just copies
> pointers around except for temporary copies made at places outside of
> schemaparse.c and friends.  We may do it with this restriction.

That's that a restriction of the caller's use not the call's functionality?
(Ie: that's internal to slapd).