Skip to content

Commit d5e4f8f

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Handle undefined dim in assign_dim_helper
2 parents e32c850 + 08c29a6 commit d5e4f8f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,12 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_obj_rw_helper(zval *object_ptr, zva
10421042

10431043
static void ZEND_FASTCALL zend_jit_assign_dim_helper(zval *object_ptr, zval *dim, zval *value, zval *result)
10441044
{
1045+
if (dim && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
1046+
const zend_op *opline = EG(current_execute_data)->opline;
1047+
zend_jit_undefined_op_helper(opline->op2.var);
1048+
dim = &EG(uninitialized_zval);
1049+
}
1050+
10451051
if (UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
10461052
const zend_op *op_data = EG(current_execute_data)->opline + 1;
10471053
ZEND_ASSERT(op_data->opcode == ZEND_OP_DATA && op_data->op1_type == IS_CV);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
JIT ASSIGN_DIM: 004
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 implements ArrayAccess {
11+
function offsetExists($x): bool {}
12+
function offsetGet($x): mixed {}
13+
function offsetSet($x, $y): void {
14+
echo "offsetSet($x, $y)\n";
15+
}
16+
function offsetUnset($x): void {}
17+
}
18+
function test() {
19+
$obj = new Test;
20+
$obj[$undef] = 1;
21+
}
22+
test();
23+
?>
24+
--EXPECTF--
25+
Warning: Undefined variable $undef in %s on line %d
26+
offsetSet(, 1)

0 commit comments

Comments
 (0)