Skip to content

Commit

Permalink
Fixed bug #74840 (Opcache overwrites argument of GENERATOR_RETURN wit…
Browse files Browse the repository at this point in the history
…hin finally)
  • Loading branch information
bwoebi committed Jul 1, 2017
1 parent 2a1ad88 commit e3cc15d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ PHP NEWS
. Fixed bug #74761 (Unary operator expected error on some systems). (petk)
. Fixed bug #73900 (Use After Free in unserialize() SplFixedArray). (nikic)

- Opcache:
. Fixed bug #74840 (Opcache overwrites argument of GENERATOR_RETURN within
finally). (Bob)

- PDO:
. Fixed bug #69356 (PDOStatement::debugDumpParams() truncates query). (Adam
Baratz)
Expand Down
21 changes: 21 additions & 0 deletions Zend/tests/bug74840.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #74840: Opcache overwrites argument of GENERATOR_RETURN within finally
--FILE--
<?php

$g = (function($a) {
try {
return $a + 1;
} finally {
$b = $a + 2;
var_dump($b);
}
yield; // Generator
})(1);
$g->next();
var_dump($g->getReturn());

?>
--EXPECT--
int(3)
int(2)
1 change: 1 addition & 0 deletions ext/opcache/Optimizer/optimize_temp_vars_5.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_ctx *c
*/
if ((op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) &&
(opline->opcode == ZEND_RETURN ||
opline->opcode == ZEND_GENERATOR_RETURN ||
opline->opcode == ZEND_RETURN_BY_REF ||
opline->opcode == ZEND_FREE ||
opline->opcode == ZEND_FE_FREE)) {
Expand Down

0 comments on commit e3cc15d

Please sign in to comment.