Skip to content

Commit 399885c

Browse files
author
Stig Venaas
committed
Fixed memory leak in ldap_get_entries() when using post RFC 1823 API.
Similar problems for other functions will be fixed
1 parent fce6f4c commit 399885c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/ldap/ldap.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,12 +945,22 @@ PHP_FUNCTION(ldap_get_entries)
945945
add_index_string(tmp1, num_attrib, attribute, 1);
946946

947947
num_attrib++;
948+
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
949+
ldap_memfree(attribute);
950+
#endif
948951
attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
949952
}
953+
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
954+
if (ber != NULL)
955+
ber_free(ber, 0);
956+
#endif
950957

951958
add_assoc_long(tmp1, "count", num_attrib);
952959
dn = ldap_get_dn(ldap, ldap_result_entry);
953960
add_assoc_string(tmp1, "dn", dn, 1);
961+
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
962+
ldap_memfree(dn);
963+
#endif
954964

955965
zend_hash_index_update(return_value->value.ht, num_entries, (void *) &tmp1, sizeof(pval *), NULL);
956966

0 commit comments

Comments
 (0)