#31348 [Asn->Csd]: CachingIterator::rewind() leaks
| From: | helly@php.net | Date: | Tue, 25 Jan 2005 22:39:00 +0000 |
| Subject: | #31348 [Asn->Csd]: CachingIterator::rewind() leaks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-72812@lists.php.net to get a copy of this message | ||
ID: 31348
Updated by: helly@php.net
Reported By: tony2001 at phpclub dot net
-Status: Assigned
+Status: Closed
Bug Type: SPL related
-Operating System: Linux 2.6.9
+Operating System: *
-PHP Version: 5CVS-2004-12-30 (dev)
+PHP Version: 5.0.3
Assigned To: helly
New Comment:
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.
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