From: tony2001 at phpclub dot net Operating system: Linux 2.6.9 PHP version: 5CVS-2004-12-30 (dev) PHP Bug Type: SPL related Bug description: CachingIterator::rewind() leaks
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 bug report at http://bugs.php.net/?id=31348&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31348&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31348&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31348&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31348&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31348&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31348&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31348&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31348&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31348&r=support Expected behavior: http://bugs.php.net/fix.php?id=31348&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31348&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31348&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31348&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31348&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31348&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31348&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31348&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31348&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31348&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31348&r=mysqlcfg