mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00

Use the general zend_generator_throw_exception() helper for this.
Otherwise we don't handle the off-by-one opline correctly (should
we maybe just stop doing that?)
This is a followup to ad750c3bb6
,
which fixed a different yield from exception handling problem that
happened to show up in the same test case from oss-fuzz #25321.
Now both issues should be fixed.
30 lines
560 B
PHP
30 lines
560 B
PHP
--TEST--
|
|
Exception from valid() during yield from
|
|
--FILE--
|
|
<?php
|
|
|
|
class FooBar implements Iterator {
|
|
function rewind() {}
|
|
function current() {}
|
|
function key() {}
|
|
function next() {}
|
|
function valid() {
|
|
throw new Exception("Exception from valid()");
|
|
}
|
|
}
|
|
|
|
function gen() {
|
|
try {
|
|
// the fact that the yield from result is used is relevant.
|
|
var_dump(yield from new FooBar);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
}
|
|
|
|
$x = gen();
|
|
$x->current();
|
|
|
|
?>
|
|
--EXPECT--
|
|
Exception from valid()
|