]> granicus.if.org Git - php/commitdiff
- Fixed bug #50185 (ldap_get_entries() return false instead of an empty array when...
authorJani Taskinen <jani@php.net>
Wed, 18 Nov 2009 17:44:58 +0000 (17:44 +0000)
committerJani Taskinen <jani@php.net>
Wed, 18 Nov 2009 17:44:58 +0000 (17:44 +0000)
# This is also revert of bad patch to bug #48469 and fixes it properly.

NEWS
ext/ldap/ldap.c

diff --git a/NEWS b/NEWS
index fac6652f103f813c0c285d4a7c158e57e2ac30d5..b29c0fe50fd6e1e35f480c7dd9ca2c419af8d96c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 
 - Made it possible to disable post_max_size (Rasmus)
 
+- Fixed bug #50185 (ldap_get_entries() return false instead of an empty array
+  when there is no error). (Jani)
 - Fixed bug #50174 (Incorrectly matched docComment). (Felipe)
 - Fixed bug #50158 (FILTER_VALIDATE_EMAIL fails with valid addresses
   containing = or ?). (Pierrick)
index 32db2138f6b6be4be5fe9b45ce267322797411bb..538ac7ce9f4ea8436419c9bfd0f961d51692c116 100644 (file)
@@ -1061,17 +1061,21 @@ PHP_FUNCTION(ldap_get_entries)
        ldap = ld->link;
        num_entries = ldap_count_entries(ldap, ldap_result);
 
-       if (num_entries == 0) return;
-       num_entries = 0;
-       
-       ldap_result_entry = ldap_first_entry(ldap, ldap_result);
-       if (ldap_result_entry == NULL) RETURN_FALSE;
-
        array_init(return_value);
        add_assoc_long(return_value, "count", num_entries);
 
-       while (ldap_result_entry != NULL) {
+       if (num_entries == 0) {
+               return;
+       }
+       
+       ldap_result_entry = ldap_first_entry(ldap, ldap_result);
+       if (ldap_result_entry == NULL) {
+               zval_dtor(return_value);
+               RETURN_FALSE;
+       }
 
+       num_entries = 0;
+       while (ldap_result_entry != NULL) {
                MAKE_STD_ZVAL(tmp1);
                array_init(tmp1);