Skip to content

Commit 6f355c6

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fixed GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error
2 parents f48ab6a + 2d65d71 commit 6f355c6

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

Diff for: ext/opcache/jit/zend_jit_helpers.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,11 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva
11281128
dim = Z_REFVAL_P(dim);
11291129
goto try_string_offset;
11301130
default:
1131-
zend_illegal_container_offset(ZSTR_KNOWN(ZEND_STR_STRING), dim, BP_VAR_IS);
1132-
break;
1131+
zend_illegal_container_offset(ZSTR_KNOWN(ZEND_STR_STRING), dim,
1132+
EG(current_execute_data)->opline->opcode == ZEND_ISSET_ISEMPTY_DIM_OBJ ?
1133+
BP_VAR_IS : BP_VAR_RW);
1134+
ZVAL_NULL(result);
1135+
return;
11331136
}
11341137

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

Diff for: 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)