ID:               31348
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tony2001 at phpclub dot net
-Status:           Open
+Status:           Assigned
 Bug Type:         SPL related
 Operating System: Linux 2.6.9
 PHP Version:      5CVS-2004-12-30 (dev)
-Assigned To:      
+Assigned To:      helly


Previous Comments:
------------------------------------------------------------------------

[2004-12-30 10:46:51] tony2001 at phpclub dot net

Description:
------------
CachingIterator::rewind() leaks some memory.
I can propose this small patch, but I'm almost sure it's not the real
solution.

Index: spl_iterators.c
===================================================================
RCS file: /repository/php-src/ext/spl/spl_iterators.c,v
retrieving revision 1.61
diff -u -r1.61 spl_iterators.c
--- spl_iterators.c     29 Dec 2004 16:11:42 -0000      1.61
+++ spl_iterators.c     30 Dec 2004 09:43:14 -0000
@@ -752,7 +752,8 @@
        }
        if (intern->dit_type == DIT_CachingIterator || intern->dit_type
== DIT_CachingRecursiveIterator) {
                if (intern->u.caching.zstr) {
-                       zval_ptr_dtor(&intern->u.caching.zstr);
+                       zval_dtor(intern->u.caching.zstr);
+                       FREE_ZVAL(intern->u.caching.zstr);
                        intern->u.caching.zstr = NULL;
                }
                if (intern->u.caching.zchildren) {

Reproduce code:
---------------
<?php
$a = Array("some","blah");
$i = new ArrayIterator($a);

$ci = new CachingIterator($i);

$ci->rewind();

echo "Done\n";
?>

Expected result:
----------------
Done

Actual result:
--------------
Done
/home/dev/php-src/ext/spl/spl_iterators.c(1276) :  Freeing 0x082E9064
(16 bytes), script=/www/index.php
/home/dev/php-src/Zend/zend_variables.h(45) :  Freeing 0x082E8E9C (5
bytes), script=/www/index.php
/home/dev/php-src/Zend/zend_variables.c(120) : Actual location
(location was relayed)
=== Total 2 memory leaks detected ===


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31348&edit=1

Reply via email to