]> granicus.if.org Git - php/commitdiff
Implement array access notice in JIT
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 10 Jul 2019 10:20:16 +0000 (12:20 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 10 Jul 2019 10:20:16 +0000 (12:20 +0200)
ext/opcache/jit/zend_jit_helpers.c
ext/opcache/jit/zend_jit_x86.dasc

index f45bfa8a39814405f86d431b919b593a5ca4e268..13309a4c11b84b5b544235a92fc3ddf3ffbef61c 100644 (file)
@@ -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);
+}
index 9f37c95770e9992af864c544895464299d4dfc27..2618adc1a507a42c5fbff524630cbf085e30a473 100644 (file)
@@ -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