1--TEST-- 2Bug #42703 (Exception raised in an iterator::current() causes segfault in FilterIterator) 3--FILE-- 4<?php 5class BlaIterator implements Iterator 6{ 7 public function rewind(): void { } 8 9 public function next(): void { } 10 11 public function valid(): bool { 12 return true; 13 } 14 15 public function current(): mixed 16 { 17 throw new Exception('boo'); 18 } 19 20 public function key(): mixed { return null; } 21} 22 23$it = new BlaIterator(); 24$itit = new IteratorIterator($it); 25 26try { 27 foreach($itit as $key => $value) { 28 echo $key, $value; 29 } 30} 31catch (Exception $e) { 32 var_dump($e->getMessage()); 33} 34 35var_dump($itit->current()); 36var_dump($itit->key()); 37?> 38--EXPECT-- 39string(3) "boo" 40NULL 41NULL 42