mirror of
https://github.com/php/php-src.git
synced 2026-04-21 15:08:16 +02:00
14f133036c
If zend_generator_close is called from within zend_generator_resume (e.g. due to a return statement) then all the EGs will still be using the values from the generator. That's why the stack frame has to be the last thing that is dtored, otherwise some other dtor that is using EG(current_execute_data) might access the already freed memory segment. This was the case with the closure dtor. The fix is to move the dtors for key and value to the start of the handler. This way the stack frame is the last thing that is freed.
18 lines
195 B
PHP
18 lines
195 B
PHP
--TEST--
|
|
Generator shouldn't crash if last yielded value is a closure
|
|
--FILE--
|
|
<?php
|
|
|
|
function gen() {
|
|
yield function() {};
|
|
}
|
|
|
|
$gen = gen();
|
|
$gen->next();
|
|
|
|
echo "Done!";
|
|
|
|
?>
|
|
--EXPECT--
|
|
Done!
|