]> granicus.if.org Git - php/commitdiff
Fixed memory leak in ldap_first_attribute(), ldap_next_attribute(),
authorStig Venaas <venaas@php.net>
Sat, 23 Jun 2001 13:43:20 +0000 (13:43 +0000)
committerStig Venaas <venaas@php.net>
Sat, 23 Jun 2001 13:43:20 +0000 (13:43 +0000)
ldap_get_attributes(), ldap_get_dn() and ldap_dn2ufn() when using post
RFC 1823 API. Still more leaks to fix.

ext/ldap/ldap.c

index 2b43fcd8e318927e30b7fa9b3093a5cfc7354012..9e1f0b7971f6b17328f9d25cafa06289635a29a6 100644 (file)
@@ -997,7 +997,7 @@ PHP_FUNCTION(ldap_first_attribute)
                ZEND_REGISTER_RESOURCE(return_value, ber, le_ber_entry);
 
                RETVAL_STRING(attribute,1);
-#ifdef WINDOWS
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
                ldap_memfree(attribute);
 #endif
        }
@@ -1028,7 +1028,7 @@ PHP_FUNCTION(ldap_next_attribute)
                ZEND_REGISTER_RESOURCE(return_value, ber, le_ber_entry);
 
                RETVAL_STRING(attribute,1);
-#ifdef WINDOWS
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
                ldap_memfree(attribute);
 #endif
        }
@@ -1075,8 +1075,15 @@ PHP_FUNCTION(ldap_get_attributes)
                add_index_string(return_value, num_attrib, attribute, 1);
 
                num_attrib++;
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
+               ldap_memfree(attribute);
+#endif
                attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
        }
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
+               if (ber != NULL)
+                       ber_free(ber, 0);
+#endif
        
        add_assoc_long(return_value, "count", num_attrib);
 }
@@ -1185,7 +1192,7 @@ PHP_FUNCTION(ldap_get_dn)
        text = ldap_get_dn(ldap, ldap_result_entry);
        if ( text != NULL ) {
                RETVAL_STRING(text,1);
-#ifdef WINDOWS
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
                ldap_memfree(text);
 #endif
        } else {
@@ -1245,7 +1252,7 @@ PHP_FUNCTION(ldap_dn2ufn)
        
        if (ufn !=NULL) {
                RETVAL_STRING(ufn,1);
-#ifdef WINDOWS
+#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
                ldap_memfree(ufn);
 #endif
        } else {