Skip to content

Commit e3cc15d

Browse files
committed
Fixed bug #74840 (Opcache overwrites argument of GENERATOR_RETURN within finally)
1 parent 2a1ad88 commit e3cc15d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fixed bug #74761 (Unary operator expected error on some systems). (petk)
1111
. Fixed bug #73900 (Use After Free in unserialize() SplFixedArray). (nikic)
1212

13+
- Opcache:
14+
. Fixed bug #74840 (Opcache overwrites argument of GENERATOR_RETURN within
15+
finally). (Bob)
16+
1317
- PDO:
1418
. Fixed bug #69356 (PDOStatement::debugDumpParams() truncates query). (Adam
1519
Baratz)

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 optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_ctx *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)