Skip to content

Commit b8ffa37

Browse files
committed
Fixed bug #76711 (OPcache enabled triggers false-positive "Illegal string offset")
1 parent f5729ec commit b8ffa37

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fixed bug #76901 (method_exists on SPL iterator passthrough method corrupts
1515
memory). (Nikita)
1616

17+
- Opcache:
18+
. Fixed bug #76711 (OPcache enabled triggers false-positive "Illegal string
19+
offset"). (Dmitry)
20+
1721
- Standard:
1822
. Fixed bug #75533 (array_reduce is slow when $carry is large array).
1923
(Manabu Matsui)

ext/opcache/Optimizer/compact_literals.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
378378
} else {
379379
map[i] = j;
380380
ZVAL_LONG(&zv, j);
381+
Z_EXTRA(op_array->literals[i]) = 0; /* allow merging with FETCH_DIM_... */
381382
zend_hash_index_add_new(&hash, Z_LVAL(op_array->literals[i]), &zv);
382383
if (i != j) {
383384
op_array->literals[j] = op_array->literals[i];

ext/opcache/tests/bug76711.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #76711 OPcache enabled triggers false-positive "Illegal string offset"
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
function test($foo) {
12+
var_dump(0);
13+
var_dump($foo[0]);
14+
}
15+
test("str");
16+
?>
17+
--EXPECT--
18+
int(0)
19+
string(1) "s"

0 commit comments

Comments
 (0)