From e3cc15daf2abc1b4886d4888c3bf5ca9cef035c8 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 1 Jul 2017 11:52:03 +0200 Subject: [PATCH] Fixed bug #74840 (Opcache overwrites argument of GENERATOR_RETURN within finally) --- NEWS | 4 ++++ Zend/tests/bug74840.phpt | 21 ++++++++++++++++++++ ext/opcache/Optimizer/optimize_temp_vars_5.c | 1 + 3 files changed, 26 insertions(+) create mode 100644 Zend/tests/bug74840.phpt diff --git a/NEWS b/NEWS index 28a7d290b2..3a97a4596b 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/Zend/tests/bug74840.phpt b/Zend/tests/bug74840.phpt new file mode 100644 index 0000000000..68e27cba84 --- /dev/null +++ b/Zend/tests/bug74840.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #74840: Opcache overwrites argument of GENERATOR_RETURN within finally +--FILE-- +next(); +var_dump($g->getReturn()); + +?> +--EXPECT-- +int(3) +int(2) diff --git a/ext/opcache/Optimizer/optimize_temp_vars_5.c b/ext/opcache/Optimizer/optimize_temp_vars_5.c index cfeb1214c8..5cc7b79e89 100644 --- a/ext/opcache/Optimizer/optimize_temp_vars_5.c +++ b/ext/opcache/Optimizer/optimize_temp_vars_5.c @@ -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)) { -- 2.49.0