#31926 [Fbk->Opn]: php in free() error with RecursiveArrayIterator

From: Date: Sat, 12 Feb 2005 17:52:21 +0000
Subject: #31926 [Fbk->Opn]: php in free() error with RecursiveArrayIterator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73948@lists.php.net to get a copy of this message
ID: 31926 User updated by: gms08701 at yahoo dot com Reported By: gms08701 at yahoo dot com -Status: Feedback +Status: Open Bug Type: SPL related Operating System: FreeBSD 5.3 PHP Version: 5.0.3 New Comment: On what OS, are you trying your my example on?? Unfortunately, I dont have the knowledge on installing php on FreeBSD (I normally install it via the port). Im currently investigating if I can overcome this. But I was tinkering with the script this morning. -- $array = array(0); class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator { function hasChildren() { return (is_array($this->current())); } function getChildren() { return new self($this->current()); } } $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($array)); while($result = $it->valid()) { var_dump($result); $it->next(); } echo "\n\n"; while($result = (bool)each($array)) { var_dump($result); } -- Notice how the 1st while loop is returning (bool)TRUE *twice*, while the 2nd loop is returning (bool)TRUE *once*. $it->valid() should return (bool)FALSE the second time it was run. Shouldn't it??? Previous Comments: ------------------------------------------------------------------------ [2005-02-11 20:56:07] tony2001@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip Works fine here. ------------------------------------------------------------------------ [2005-02-11 03:10:21] gms08701 at yahoo dot com Description: ------------ Trying to create a RecursiveArrayIterator class, using currently available SPL classes. Its generating this error -> php in free(): warning: chunk is already free Apparently it works on win2k -> http://marc.theaimsgroup.com/?l=php-general&m=110807956115501&w=2 Reproduce code: --------------- <?php $array = array(0 => array('world')); class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator { function hasChildren() { return (is_array($this->current())); } function getChildren() { return new self($this->current()); } } $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($array)); foreach($it as $key => $val) { var_dump($key, $val); } ?> Expected result: ---------------- $ php -f z.php int(0) string(5) "world" Actual result: -------------- $ php -f z.php int(0) string(5) "world" php in free(): warning: chunk is already free ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31926&edit=1

« previous php.bugs (#73948) next »