Skip to content

Commit 52463ae

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: jit: fixed "Uninitialized string offset" warning being emitted at the same time as invalid offset Error
2 parents 3269aa9 + ed8b901 commit 52463ae

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ PHP NEWS
1111
. Fixed bug GH-12791 (Possible dereference of NULL in MySQLnd debug code).
1212
(nielsdos)
1313

14+
- Opcache:
15+
. Fixed JIT bug (Function JIT emits "Uninitialized string offset" warning
16+
at the same time as invalid offset Error). (Girgias)
17+
1418
- Standard
1519
. Fixed GH-12745 (http_build_query() default null argument for $arg_separator
1620
is implicitly coerced to string). (Girgias)

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,9 @@ static zend_string* ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zend_string *s
11001100
} else {
11011101
offset = Z_LVAL_P(dim);
11021102
}
1103+
if (UNEXPECTED(EG(exception) != NULL)) {
1104+
return ZSTR_EMPTY_ALLOC();
1105+
}
11031106
return zend_jit_fetch_dim_str_offset(str, offset);
11041107
}
11051108

ext/opcache/tests/jit/gh12723-A.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-12723: Function JIT emits "Uninitialized string offset" warning at the same time as invalid offset Error
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--FILE--
7+
<?php
8+
9+
$container = '';
10+
$dimension = [];
11+
12+
try {
13+
var_dump($container[$dimension]);
14+
} catch (\Throwable $e) {
15+
echo $e->getMessage(), "\n";
16+
}
17+
18+
?>
19+
--EXPECT--
20+
Cannot access offset of type array on string

0 commit comments

Comments
 (0)