From: Nikita Popov Date: Wed, 10 Jul 2019 10:20:16 +0000 (+0200) Subject: Implement array access notice in JIT X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26431d1995861b979643b7233f5253390551bcad;p=php Implement array access notice in JIT --- diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index f45bfa8a39..13309a4c11 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1604,3 +1604,9 @@ static void ZEND_FASTCALL zend_jit_only_vars_by_reference(zval *arg) ZVAL_NEW_REF(arg, arg); zend_error(E_NOTICE, "Only variables should be passed by reference"); } + +static void ZEND_FASTCALL zend_jit_invalid_array_access(zval *container) +{ + const char *type = Z_ISUNDEF_P(container) ? "null" : zend_zval_type_name(container); + zend_error(E_NOTICE, "Trying to access array offset on value of type %s", type); +} diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 9f37c95770..2618adc1a5 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -8884,6 +8884,11 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, zend } if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT))) { + if (opline->opcode != ZEND_FETCH_DIM_IS) { + | SAVE_VALID_OPLINE opline + | LOAD_ZVAL_ADDR FCARG1a, op1_addr + | EXT_CALL zend_jit_invalid_array_access, r0 + } | SET_ZVAL_TYPE_INFO res_addr, IS_NULL if (op1_info & MAY_BE_ARRAY) { | jmp >9 // END