mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fixed GH-12747: Function JIT returns invalid error message for coalesce operator on invalid offset
This commit is contained in:
@@ -620,7 +620,9 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim
|
||||
hval = 1;
|
||||
goto num_index;
|
||||
default:
|
||||
zend_illegal_container_offset(ZSTR_KNOWN(ZEND_STR_ARRAY), dim, BP_VAR_IS);
|
||||
zend_illegal_container_offset(ZSTR_KNOWN(ZEND_STR_ARRAY), dim,
|
||||
EG(current_execute_data)->opline->opcode == ZEND_ISSET_ISEMPTY_DIM_OBJ ?
|
||||
BP_VAR_IS : BP_VAR_RW);
|
||||
undef_result_after_exception();
|
||||
return;
|
||||
}
|
||||
|
||||
35
ext/opcache/tests/jit/gh12747.phpt
Normal file
35
ext/opcache/tests/jit/gh12747.phpt
Normal file
@@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
GH-12747: Function JIT returns invalid error message for coalesce operator on invalid offset
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
--FILE--
|
||||
<?php
|
||||
$container = [];
|
||||
// Is
|
||||
try {
|
||||
echo "isset():\n";
|
||||
var_dump(isset($container[new stdClass()]));
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
echo "empty():\n";
|
||||
var_dump(empty($container[new stdClass()]));
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
echo "Coalesce():\n";
|
||||
var_dump($container[new stdClass()] ?? 'default');
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
isset():
|
||||
Cannot access offset of type stdClass in isset or empty
|
||||
empty():
|
||||
Cannot access offset of type stdClass in isset or empty
|
||||
Coalesce():
|
||||
Cannot access offset of type stdClass on array
|
||||
Reference in New Issue
Block a user