Fixed GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error

This commit is contained in:
Dmitry Stogov 2023-11-22 13:19:10 +03:00
parent 6be4ba9f90
commit 2d65d714a3
2 changed files with 37 additions and 1 deletions

View file

@ -1135,7 +1135,8 @@ try_string_offset:
goto try_string_offset;
default:
zend_jit_illegal_string_offset(dim);
break;
ZVAL_NULL(result);
return;
}
offset = zval_get_long_func(dim, /* is_strict */ false);

View file

@ -0,0 +1,35 @@
--TEST--
GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error
--INI--
opcache.enable=1
opcache.enable_cli=1
--FILE--
<?php
$container = "string";
// 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():
bool(false)
empty():
bool(true)
Coalesce():
Cannot access offset of type stdClass on string