xref: /PHP-8.4/Zend/tests/bug30725.phpt (revision 75a678a7)
1--TEST--
2Bug #30725 (PHP segfaults when an exception is thrown in getIterator() within foreach)
3--FILE--
4<?php
5
6class Test implements IteratorAggregate
7{
8    function getIterator(): Traversable
9    {
10        throw new Exception();
11    }
12}
13
14try
15{
16    $it = new Test;
17    foreach($it as $v)
18    {
19        echo "Fail\n";
20    }
21    echo "Wrong\n";
22}
23catch(Exception $e)
24{
25    echo "Caught\n";
26}
27
28?>
29--EXPECT--
30Caught
31