php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48469 ldap_get_entries() memory leaks when used on a search yielding no results
Submitted: 2009-06-04 08:51 UTC Modified: 2009-06-07 13:15 UTC
From: patrickallaert@php.net Assigned: patrickallaert (profile)
Status: Closed Package: LDAP related
PHP Version: 5.*, 6CVS (2009-06-04) OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: patrickallaert@php.net
New email:
PHP Version: OS:

 

 [2009-06-04 08:51 UTC] patrickallaert@php.net
Description:
------------
Memory leaks found when using ldap_get_entries() which returns NULL

Reproduce code:
---------------
<?php
ldap_get_entries(
    $link,
    ldap_search(
        $link,
        "dc=my-domain,dc=com",
        "(o=unexisting-domain)"
    )
);
?>

Actual result:
--------------
[Thu Jun  4 10:36:15 2009]  Script:  '/usr/src/php-5.3-
cvs/ext/ldap/tests/ldap_get_entries_variation.php'
/usr/src/php-5.3-cvs/Zend/zend_hash.c(247) :  Freeing 0x12D749F8 (41 
bytes), script=/usr/src/php-5.3-
cvs/ext/ldap/tests/ldap_get_entries_variation.php
[Thu Jun  4 10:36:15 2009]  Script:  '/usr/src/php-5.3-
cvs/ext/ldap/tests/ldap_get_entries_variation.php'
/usr/src/php-5.3-cvs/ext/ldap/ldap.c(964) :  Freeing 0x12D75B14 (44 
bytes), script=/usr/src/php-5.3-
cvs/ext/ldap/tests/ldap_get_entries_variation.php
/usr/src/php-5.3-cvs/Zend/zend_API.c(936) : Actual location (location 
was relayed)
Last leak repeated 1 time
[Thu Jun  4 10:36:15 2009]  Script:  '/usr/src/php-5.3-
cvs/ext/ldap/tests/ldap_get_entries_variation.php'
/usr/src/php-5.3-cvs/Zend/zend_API.c(1096) :  Freeing 0x12D7699C (20 
bytes), script=/usr/src/php-5.3-
cvs/ext/ldap/tests/ldap_get_entries_variation.php
=== Total 4 memory leaks detected ===

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-04 08:55 UTC] patrickallaert@php.net
The patch below corrects this problem.

Ok to commit this in HEAD followed by branches with MFH?

Index: ext/ldap/ldap.c
===================================================================
RCS file: /repository/php-src/ext/ldap/ldap.c,v
retrieving revision 1.161.2.3.2.11.2.25
diff -u -r1.161.2.3.2.11.2.25 ldap.c
--- ext/ldap/ldap.c     21 Apr 2009 18:08:34 -0000      
1.161.2.3.2.11.2.25
+++ ext/ldap/ldap.c     4 Jun 2009 08:53:25 -0000
@@ -961,9 +961,6 @@
        ldap = ld->link;
        num_entries = ldap_count_entries(ldap, ldap_result);

-       array_init(return_value);
-       add_assoc_long(return_value, "count", num_entries);
-
        if (num_entries == 0) {
                RETURN_NULL();
        }
@@ -974,6 +971,9 @@
                RETURN_FALSE;
        }

+       array_init(return_value);
+       add_assoc_long(return_value, "count", num_entries);
+
        while (ldap_result_entry != NULL) {

                MAKE_STD_ZVAL(tmp1);

 [2009-06-04 09:00 UTC] pajoye@php.net
You have the karma to commit yourself right?

If yes and if you have a test for this bug, simply commit both :)
 [2009-06-07 13:15 UTC] patrickallaert@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-11-18 17:44 UTC] svn@php.net
Automatic comment from SVN on behalf of jani
Revision: http://svn.php.net/viewvc/?view=revision&revision=290923
Log: - 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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 21:01:28 2024 UTC