]> granicus.if.org Git - php/commitdiff
Fixed bug #76094 (Access violation when using opcache)
authorXinchen Hui <laruence@gmail.com>
Thu, 15 Mar 2018 03:17:00 +0000 (11:17 +0800)
committerXinchen Hui <laruence@gmail.com>
Thu, 15 Mar 2018 03:17:00 +0000 (11:17 +0800)
NEWS
ext/opcache/Optimizer/dce.c
ext/opcache/tests/bug76094.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 46db91b9908a651cf641df97071ead6de1d29fe9..4882f007b45516e9406fcb548f781fc61753fcb6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ PHP                                                                        NEWS
   . Fixed bug #76088 (ODBC functions are not available by default on Windows).
     (cmb)
 
+- Opcache:
+  . Fixed bug #76094 (Access violation when using opcache). (Laruence)
+
 - Standard:
   . Fixed bug #74139 (mail.add_x_header default inconsistent with docs). (cmb)
 
index 358870beafda80122eaff105a7fd7e007d51d7d9..c146599a353a40adbcb51ae19c16fecb1f94bc46 100644 (file)
@@ -356,7 +356,8 @@ static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
 
        if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))&& !is_var_dead(ctx, ssa_op->op1_use)) {
                if (!try_remove_var_def(ctx, ssa_op->op1_use, ssa_op->op1_use_chain, opline)) {
-                       if (ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
+                       if (ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)
+                               && opline->opcode != ZEND_CASE) {
                                free_var = ssa_op->op1_use;
                                free_var_type = opline->op1_type;
                        }
diff --git a/ext/opcache/tests/bug76094.phpt b/ext/opcache/tests/bug76094.phpt
new file mode 100644 (file)
index 0000000..4f5e037
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Bug #76094 (Access violation when using opcache)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function MetaType($t)
+{
+
+       switch (strtoupper($t)) {
+       case PHP_INT_MAX :
+               return 1;
+       case 0:
+       default:
+               return 0;
+       }
+}
+
+var_dump(MetaType("aa"));
+?>
+--EXPECT--
+int(0)