Skip to content

Commit 2d65d71

Browse files
committed
Fixed GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error
1 parent 6be4ba9 commit 2d65d71

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

ext/opcache/jit/zend_jit_helpers.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva
11351135
goto try_string_offset;
11361136
default:
11371137
zend_jit_illegal_string_offset(dim);
1138-
break;
1138+
ZVAL_NULL(result);
1139+
return;
11391140
}
11401141

11411142
offset = zval_get_long_func(dim, /* is_strict */ false);

ext/opcache/tests/jit/gh12748.phpt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
GH-12748: Function JIT emits "could not convert to int" 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+
$container = "string";
9+
// Is
10+
try {
11+
echo "isset():\n";
12+
var_dump(isset($container[new stdClass()]));
13+
} catch (\Throwable $e) {
14+
echo $e->getMessage(), "\n";
15+
}
16+
try {
17+
echo "empty():\n";
18+
var_dump(empty($container[new stdClass()]));
19+
} catch (\Throwable $e) {
20+
echo $e->getMessage(), "\n";
21+
}
22+
try {
23+
echo "Coalesce():\n";
24+
var_dump($container[new stdClass()] ?? 'default');
25+
} catch (\Throwable $e) {
26+
echo $e->getMessage(), "\n";
27+
}
28+
?>
29+
--EXPECT--
30+
isset():
31+
bool(false)
32+
empty():
33+
bool(true)
34+
Coalesce():
35+
Cannot access offset of type stdClass on string

0 commit comments

Comments
 (0)