summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-09-20 12:33:46 +0300
committerDmitry Stogov <dmitry@zend.com>2018-09-20 12:33:46 +0300
commitb8ffa3707c07e6edbe5db5a3fdf5516ba1f6bef0 (patch)
tree50737b90e5c7656f38f0c44f7d1c834c1791b2e8
parentf5729ec53224fd13e680825b0a71675be96fed53 (diff)
downloadphp-git-b8ffa3707c07e6edbe5db5a3fdf5516ba1f6bef0.tar.gz
Fixed bug #76711 (OPcache enabled triggers false-positive "Illegal string offset")
-rw-r--r--NEWS4
-rw-r--r--ext/opcache/Optimizer/compact_literals.c1
-rw-r--r--ext/opcache/tests/bug76711.phpt19
3 files changed, 24 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index a815840809..5fd64d6bd8 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ PHP NEWS
. Fixed bug #76901 (method_exists on SPL iterator passthrough method corrupts
memory). (Nikita)
+- Opcache:
+ . Fixed bug #76711 (OPcache enabled triggers false-positive "Illegal string
+ offset"). (Dmitry)
+
- Standard:
. Fixed bug #75533 (array_reduce is slow when $carry is large array).
(Manabu Matsui)
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c
index e10b9feab0..065962be73 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -378,6 +378,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
} else {
map[i] = j;
ZVAL_LONG(&zv, j);
+ Z_EXTRA(op_array->literals[i]) = 0; /* allow merging with FETCH_DIM_... */
zend_hash_index_add_new(&hash, Z_LVAL(op_array->literals[i]), &zv);
if (i != j) {
op_array->literals[j] = op_array->literals[i];
diff --git a/ext/opcache/tests/bug76711.phpt b/ext/opcache/tests/bug76711.phpt
new file mode 100644
index 0000000000..781312503b
--- /dev/null
+++ b/ext/opcache/tests/bug76711.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #76711 OPcache enabled triggers false-positive "Illegal string offset"
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function test($foo) {
+ var_dump(0);
+ var_dump($foo[0]);
+}
+test("str");
+?>
+--EXPECT--
+int(0)
+string(1) "s"