Skip to content

Commit ad40fff

Browse files
committed
Fixed Bug GH-8863: RW operation on readonly property doesn't throw with JIT
1 parent bf29ee6 commit ad40fff

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,6 +2558,11 @@ static void ZEND_FASTCALL zend_jit_assign_op_to_typed_prop(zval *zptr, zend_prop
25582558
zend_execute_data *execute_data = EG(current_execute_data);
25592559
zval z_copy;
25602560

2561+
if (UNEXPECTED(prop_info->flags & ZEND_ACC_READONLY)) {
2562+
zend_readonly_property_modification_error(prop_info);
2563+
return;
2564+
}
2565+
25612566
ZVAL_DEREF(zptr);
25622567
/* Make sure that in-place concatenation is used if the LHS is a string. */
25632568
if (binary_op == concat_function && Z_TYPE_P(zptr) == IS_STRING) {

ext/opcache/tests/jit/gh8863.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug GH-8863: RW operation on readonly property doesn't throw with JIT
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
class Test {
11+
public readonly int $prop;
12+
13+
public function __construct() {
14+
$this->prop = 1;
15+
}
16+
17+
public function rw() {
18+
$this->prop += 1;
19+
echo "Done\n";
20+
}
21+
}
22+
23+
$test = new Test();
24+
try {
25+
$test->rw();
26+
} catch (Error $e) {
27+
echo $e->getMessage(), "\n";
28+
}
29+
?>
30+
DONE
31+
--EXPECT--
32+
Cannot modify readonly property Test::$prop
33+
DONE

0 commit comments

Comments
 (0)