]> granicus.if.org Git - php/commitdiff
ZEND_SEPARATE reuses temporaries
authorNikita Popov <nikic@php.net>
Tue, 7 Jul 2015 22:12:47 +0000 (00:12 +0200)
committerNikita Popov <nikic@php.net>
Tue, 7 Jul 2015 22:13:23 +0000 (00:13 +0200)
Zend/tests/temporary_cleaning_006.phpt [new file with mode: 0644]
Zend/zend_opcode.c

diff --git a/Zend/tests/temporary_cleaning_006.phpt b/Zend/tests/temporary_cleaning_006.phpt
new file mode 100644 (file)
index 0000000..758260d
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Exception after separation during indirect write to fcall result
+--FILE--
+<?php
+
+function throwing() { throw new Exception; }
+
+function getArray() { return [0]; }
+
+try {
+    getArray()[throwing()] = 1;
+} catch (Exception $e) {
+    echo "Exception\n";
+}
+
+?>
+--EXPECT--
+Exception
index 8f3ecddbda6d3a32a664b5f8c3588da9130dc7eb..f8d040468f0239e18c6972c2bb054de8388e455f 100644 (file)
@@ -950,6 +950,7 @@ static zend_always_inline uint32_t *generate_var_liveliness_info_ex(zend_op_arra
                        /* the following opcodes reuse TMP created before */
                        && opline->opcode != ZEND_ROPE_ADD
                        && opline->opcode != ZEND_ADD_ARRAY_ELEMENT
+                       && opline->opcode != ZEND_SEPARATE
                        /* passes fast_call */
                        && opline->opcode != ZEND_FAST_CALL
                        /* the following opcodes pass class_entry */
@@ -980,6 +981,7 @@ static zend_always_inline uint32_t *generate_var_liveliness_info_ex(zend_op_arra
                        if (Tstart[var] != (uint32_t)-1
                                /* the following opcodes don't free TMP */
                                && opline->opcode != ZEND_ROPE_ADD
+                               && opline->opcode != ZEND_SEPARATE
                                && opline->opcode != ZEND_FETCH_LIST
                                && opline->opcode != ZEND_CASE
                                && opline->opcode != ZEND_FE_FETCH_R