Skip to content

Commit 26431d1

Browse files
committed
Implement array access notice in JIT
1 parent 106f71c commit 26431d1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,3 +1604,9 @@ static void ZEND_FASTCALL zend_jit_only_vars_by_reference(zval *arg)
16041604
ZVAL_NEW_REF(arg, arg);
16051605
zend_error(E_NOTICE, "Only variables should be passed by reference");
16061606
}
1607+
1608+
static void ZEND_FASTCALL zend_jit_invalid_array_access(zval *container)
1609+
{
1610+
const char *type = Z_ISUNDEF_P(container) ? "null" : zend_zval_type_name(container);
1611+
zend_error(E_NOTICE, "Trying to access array offset on value of type %s", type);
1612+
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8884,6 +8884,11 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend
88848884
}
88858885

88868886
if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT))) {
8887+
if (opline->opcode != ZEND_FETCH_DIM_IS) {
8888+
| SAVE_VALID_OPLINE opline
8889+
| LOAD_ZVAL_ADDR FCARG1a, op1_addr
8890+
| EXT_CALL zend_jit_invalid_array_access, r0
8891+
}
88878892
| SET_ZVAL_TYPE_INFO res_addr, IS_NULL
88888893
if (op1_info & MAY_BE_ARRAY) {
88898894
| jmp >9 // END

0 commit comments

Comments
 (0)