php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37457 Crash when an exception is thrown in accept() method of FilterIterator
Submitted: 2006-05-16 08:00 UTC Modified: 2006-05-16 08:23 UTC
From: jaco at welnet dot nl Assigned: helly (profile)
Status: Closed Package: SPL related
PHP Version: 5.1.* OS: *
Private report: No CVE-ID: None
 [2006-05-16 08:00 UTC] jaco at welnet dot nl
Description:
------------
Filtering an object which implements Iterator produces the error below, but an ArrayIterator works fine.





Reproduce code:
---------------
<?
class Collection implements Iterator {
	
	protected $array, $valid = false;
	
	public function __construct(array $a) { $this->array = $a; }
	
	public function current() { return current($this->array); }
	public function key() { return key($this->array); }
	public function next() { $this->valid = (false !== next($this->array)); }
	public function valid() { return $this->valid; }
	public function rewind() { $this->valid = (false !== reset($this->array)); }
}

class TestFilter extends FilterIterator {
    public function accept() { throw new Exception("Me crash!"); }
}

$test = new TestFilter( new Collection(array(0)) );

foreach ($test as $item) {
	echo $item;
}
?>

Expected result:
----------------
Uncaught exception message.

Actual result:
--------------
From CLI:
Fatal error: Couldn't execute method Collection::next in Unknown on line 0.

As a httpd module it only prints garbage characters on screen.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-16 08:22 UTC] helly@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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC