]> granicus.if.org Git - php/commitdiff
Fixed bug #71843 (null ptr deref ZEND_RETURN_SPEC_CONST_HANDLER)
authorXinchen Hui <laruence@gmail.com>
Thu, 17 Mar 2016 11:06:50 +0000 (19:06 +0800)
committerXinchen Hui <laruence@gmail.com>
Thu, 17 Mar 2016 11:54:19 +0000 (19:54 +0800)
NEWS
ext/opcache/Optimizer/block_pass.c
ext/opcache/tests/bug71843.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 5ffad7624a65bbcbf75aba8ae5625d09b5fb688e..9a200f9a10ae737bc8e5413ea7a9113bde31de2f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ PHP                                                                        NEWS
 - Core: 
   . Fixed bug #71841 (EG(error_zval) is not handled well). (Laruence)
 
+- Opcache:
+  . Fixed bug #71843 (null ptr deref ZEND_RETURN_SPEC_CONST_HANDLER).
+    (Laruence)
+
 - Standard:
   . Fixed bug #71840 (Unserialize accepts wrongly data). (Ryat, Laruence)
 
index c146d0cc8cbd7af95a71352ff19b7fa0de5d207a..bf3f144cc1b36477133d1b9bf8ef4fcaae4cf81d 100644 (file)
@@ -716,8 +716,11 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
                        if (src->opcode == ZEND_BOOL) {
                                if (ZEND_OP1_TYPE(src) == IS_CONST) {
                                        literal_dtor(&ZEND_OP1_LITERAL(src));
+                               } else if (ZEND_OP1_TYPE(src) == IS_TMP_VAR) {
+                                       src->opcode = ZEND_FREE;
+                               } else {
+                                       MAKE_NOP(src);
                                }
-                               MAKE_NOP(src);
                                MAKE_NOP(opline);
                        }
                }
diff --git a/ext/opcache/tests/bug71843.phpt b/ext/opcache/tests/bug71843.phpt
new file mode 100644 (file)
index 0000000..7fcf32c
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #71843 (null ptr deref ZEND_RETURN_SPEC_CONST_HANDLER (zend_vm_execute.h:3479))
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=0xFFFFBFFF
+--SKIPIF--
+<?php if (!extension_loaded('Zend OPcache')) die("skip"); ?>
+--FILE--
+<?
+0 & ~E & ~R;
+6 && ~See
+?>
+okey
+--EXPECTF--
+Notice: Use of undefined constant E - assumed 'E' in %sbug71843.php on line %d
+
+Notice: Use of undefined constant R - assumed 'R' in %sbug71843.php on line %d
+
+Notice: Use of undefined constant See - assumed 'See' in %sbug71843.php on line %d
+okey