Skip to content

Commit bd2c970

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

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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)