From 2ce1d0056d33444984663e53264d2584ec6a6f69 Mon Sep 17 00:00:00 2001 From: Jani Taskinen Date: Wed, 18 Nov 2009 17:44:58 +0000 Subject: [PATCH] - Fixed bug #50185 (ldap_get_entries() return false instead of an empty array when there is no error). # This is also revert of bad patch to bug #48469 and fixes it properly. --- NEWS | 2 ++ ext/ldap/ldap.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index fac6652f10..b29c0fe50f 100644 --- 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) diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 32db2138f6..538ac7ce9f 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -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); -- 2.50.1