Fixed Bug GH-8863: RW operation on readonly property doesn't throw with JIT

This commit is contained in:
Dmitry Stogov 2022-06-27 14:25:30 +03:00
parent bf29ee6917
commit ad40fffd36
2 changed files with 38 additions and 0 deletions

View file

@ -2558,6 +2558,11 @@ static void ZEND_FASTCALL zend_jit_assign_op_to_typed_prop(zval *zptr, zend_prop
zend_execute_data *execute_data = EG(current_execute_data);
zval z_copy;
if (UNEXPECTED(prop_info->flags & ZEND_ACC_READONLY)) {
zend_readonly_property_modification_error(prop_info);
return;
}
ZVAL_DEREF(zptr);
/* Make sure that in-place concatenation is used if the LHS is a string. */
if (binary_op == concat_function && Z_TYPE_P(zptr) == IS_STRING) {

View file

@ -0,0 +1,33 @@
--TEST--
Bug GH-8863: RW operation on readonly property doesn't throw with JIT
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
class Test {
public readonly int $prop;
public function __construct() {
$this->prop = 1;
}
public function rw() {
$this->prop += 1;
echo "Done\n";
}
}
$test = new Test();
try {
$test->rw();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
DONE
--EXPECT--
Cannot modify readonly property Test::$prop
DONE