|  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
Status: Closed Package: SPL related
PHP Version: 5.1.* OS: *
Private report: No CVE-ID:
 [2006-05-16 08:00 UTC] jaco at welnet dot nl
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-16 08:22 UTC]
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
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 14:01:33 2015 UTC