]> granicus.if.org Git - php/commitdiff
Fixed bug #74840 (Opcache overwrites argument of GENERATOR_RETURN within finally)
authorBob Weinand <bobwei9@hotmail.com>
Sat, 1 Jul 2017 09:52:03 +0000 (11:52 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Sat, 1 Jul 2017 09:52:03 +0000 (11:52 +0200)
NEWS
Zend/tests/bug74840.phpt [new file with mode: 0644]
ext/opcache/Optimizer/optimize_temp_vars_5.c

diff --git a/NEWS b/NEWS
index 28a7d290b283d0cc8ee84d58ab3a789fdef3034b..3a97a4596bd5fc225cc156310c6ea2dd0ce3b872 100644 (file)
--- 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 (file)
index 0000000..68e27cb
--- /dev/null
@@ -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)
index cfeb1214c8cdcdd57ff3b813c9ea6d5d22358a02..5cc7b79e89b2061826c47b6134277801a10bf700 100644 (file)
@@ -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)) {