Skip to content

Commit af7bfc7

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
2 parents 72f7143 + e3cc15d commit af7bfc7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Zend/tests/bug74840.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #74840: Opcache overwrites argument of GENERATOR_RETURN within finally
3+
--FILE--
4+
<?php
5+
6+
$g = (function($a) {
7+
try {
8+
return $a + 1;
9+
} finally {
10+
$b = $a + 2;
11+
var_dump($b);
12+
}
13+
yield; // Generator
14+
})(1);
15+
$g->next();
16+
var_dump($g->getReturn());
17+
18+
?>
19+
--EXPECT--
20+
int(3)
21+
int(2)

ext/opcache/Optimizer/optimize_temp_vars_5.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void zend_optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_c
109109
*/
110110
if ((op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) &&
111111
(opline->opcode == ZEND_RETURN ||
112+
opline->opcode == ZEND_GENERATOR_RETURN ||
112113
opline->opcode == ZEND_RETURN_BY_REF ||
113114
opline->opcode == ZEND_FREE ||
114115
opline->opcode == ZEND_FE_FREE)) {

0 commit comments

Comments
 (0)