Skip to content

Commit a03cb13

Browse files
committed
JIT: Fix FFI pointer access through FETCH_DIM, ASSIGN_DIM
1 parent 2e381d1 commit a03cb13

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ext/opcache/jit/zend_jit_ir.c

+15
Original file line numberDiff line numberDiff line change
@@ -12443,6 +12443,11 @@ static int zend_jit_ffi_fetch_dim_read(zend_jit_ctx *jit,
1244312443

1244412444
ir_ref obj_ref = jit_Z_PTR(jit, op1_addr);
1244512445
ir_ref cdata_ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_ffi_cdata, ptr)));
12446+
12447+
if (op1_ffi_type->kind == ZEND_FFI_TYPE_POINTER) {
12448+
cdata_ref = ir_LOAD_A(cdata_ref);
12449+
}
12450+
1244612451
ir_ref ptr = ir_ADD_A(cdata_ref, ir_MUL_L(jit_Z_LVAL(jit, op2_addr), ir_CONST_LONG(el_type->size)));
1244712452

1244812453
switch (el_type->kind) {
@@ -13181,6 +13186,11 @@ static int zend_jit_ffi_assign_dim(zend_jit_ctx *jit,
1318113186

1318213187
ir_ref obj_ref = jit_Z_PTR(jit, op1_addr);
1318313188
ir_ref cdata_ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_ffi_cdata, ptr)));
13189+
13190+
if (op1_ffi_type->kind == ZEND_FFI_TYPE_POINTER) {
13191+
cdata_ref = ir_LOAD_A(cdata_ref);
13192+
}
13193+
1318413194
ir_ref ptr = ir_ADD_A(cdata_ref, ir_MUL_L(jit_Z_LVAL(jit, op2_addr), ir_CONST_LONG(el_type->size)));
1318513195

1318613196
ZEND_ASSERT(!res_addr);
@@ -13644,6 +13654,11 @@ static int zend_jit_ffi_assign_dim_op(zend_jit_ctx *jit,
1364413654

1364513655
ir_ref obj_ref = jit_Z_PTR(jit, op1_addr);
1364613656
ir_ref cdata_ref = ir_LOAD_A(ir_ADD_OFFSET(obj_ref, offsetof(zend_ffi_cdata, ptr)));
13657+
13658+
if (op1_ffi_type->kind == ZEND_FFI_TYPE_POINTER) {
13659+
cdata_ref = ir_LOAD_A(cdata_ref);
13660+
}
13661+
1364713662
ir_ref ptr = ir_ADD_A(cdata_ref, ir_MUL_L(jit_Z_LVAL(jit, op2_addr), ir_CONST_LONG(el_type->size)));
1364813663

1364913664
if (!zend_jit_ffi_assign_op_helper(jit, opline, opline->extended_value,

0 commit comments

Comments
 (0)