mirror of
https://github.com/php/php-src.git
synced 2024-09-29 05:46:06 +00:00
64a643a4e3
If the generator is closed before it has finished running, it may happen that some FREE or SWITCH_FREE opcodes haven't been executed and memory is leaked. This fixes it by walking the brk_cont_array and manually freeing the variables.
20 lines
316 B
PHP
20 lines
316 B
PHP
--TEST--
|
|
foreach() (and other) variables aren't leaked on premature close
|
|
--FILE--
|
|
<?php
|
|
|
|
function *gen(array $array) {
|
|
foreach ($array as $value) {
|
|
yield $value;
|
|
}
|
|
}
|
|
|
|
$gen = gen(['Foo', 'Bar']);
|
|
var_dump($gen->current());
|
|
|
|
// generator is closed here, without running SWITCH_FREE
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(3) "Foo"
|