Skip to content

Commit 4d606cf

Browse files
committed
Merge branch 'PHP-5.5'
2 parents 4cf2065 + 0f36224 commit 4d606cf

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

Zend/tests/generators/bug65035.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #65035: yield / exit segfault
3+
--FILE--
4+
<?php
5+
6+
function gen() {
7+
fn();
8+
yield;
9+
}
10+
11+
function fn() {
12+
exit('Done');
13+
}
14+
15+
$gen = gen();
16+
$gen->current();
17+
18+
?>
19+
--EXPECT--
20+
Done

Zend/tests/generators/bug65161.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #65161: Generator + autoload + syntax error = segfault
3+
--FILE--
4+
<?php
5+
6+
function autoload() {
7+
foo();
8+
}
9+
spl_autoload_register('autoload');
10+
11+
function testGenerator() {
12+
new SyntaxError('param');
13+
yield;
14+
}
15+
16+
foreach (testGenerator() as $i);
17+
18+
?>
19+
--EXPECTF--
20+
Fatal error: Call to undefined function foo() in %s on line %d

Zend/zend_generators.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
5555
zval_ptr_dtor(&execute_data->current_this);
5656
}
5757

58+
/* A fatal error / die occured during the generator execution. Trying to clean
59+
* up the stack may not be safe in this case. */
60+
if (CG(unclean_shutdown)) {
61+
return;
62+
}
63+
5864
/* If the generator is closed before it can finish execution (reach
5965
* a return statement) we have to free loop variables manually, as
6066
* we don't know whether the SWITCH_FREE / FREE opcodes have run */

0 commit comments

Comments
 (0)