From: Randy Kunkee Date: Tue, 10 Jul 2001 22:11:57 +0000 (+0000) Subject: Call ldap_memfree(attributeName) for returns from ldap_first_attribute() X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1243 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d304d012af0ba73c90e321ae498acf97d8731a33;p=openldap Call ldap_memfree(attributeName) for returns from ldap_first_attribute() and ldap_next_attribute if using newer interface. Current test for this is an #if LDAP_API_VERSION >= 2004. --- diff --git a/contrib/ldaptcl/neoXldap.c b/contrib/ldaptcl/neoXldap.c index e347962a50..a9f1a8f2b9 100644 --- a/contrib/ldaptcl/neoXldap.c +++ b/contrib/ldaptcl/neoXldap.c @@ -212,6 +212,11 @@ LDAP_ProcessOneSearchResult (interp, ldap, entry, destArrayNameObj, evalCodeObj) } attributeNameObj = Tcl_NewObj(); Tcl_IncrRefCount (attributeNameObj); + + /* Note that attributeName below is allocated for OL2+ libldap, so it + must be freed with ldap_memfree(). Test below is admittedly a hack. + */ + for (attributeName = ldap_first_attribute (ldap, entry, &ber); attributeName != NULL; attributeName = ldap_next_attribute(ldap, entry, ber)) { @@ -227,6 +232,9 @@ LDAP_ProcessOneSearchResult (interp, ldap, entry, destArrayNameObj, evalCodeObj) */ attributeDataObj = Tcl_NewObj(); Tcl_SetStringObj(attributeNameObj, attributeName, -1); +#if LDAP_API_VERSION >= 2004 + ldap_memfree(attributeName); /* free if newer API */ +#endif for (i = 0; bvals[i] != NULL; i++) { Tcl_Obj *singleAttributeValueObj;