mirror of
https://github.com/php/php-src.git
synced 2024-11-30 21:35:36 +08:00
Fix handling of exception if valid() during yield from
Fixes oss-fuzz #25296.
This commit is contained in:
parent
376bbbdf3b
commit
ad750c3bb6
29
Zend/tests/generators/yield_from_valid_exception.phpt
Normal file
29
Zend/tests/generators/yield_from_valid_exception.phpt
Normal file
@ -0,0 +1,29 @@
|
||||
--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 {
|
||||
yield from new FooBar;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$x = gen();
|
||||
$x->current();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Exception from valid()
|
@ -709,6 +709,9 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
|
||||
}
|
||||
|
||||
if (iter->funcs->valid(iter) == FAILURE) {
|
||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||
goto exception;
|
||||
}
|
||||
/* reached end of iteration */
|
||||
goto failure;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user