From: Dmitry Stogov Date: Tue, 12 Apr 2016 21:05:19 +0000 (+0300) Subject: Delay IS_UNDEF check for FETCH_DIM_R and family X-Git-Tag: php-7.1.0alpha1~329^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b3e2fe2b1798228248f8d8f926d427210fa6bbb;p=php Delay IS_UNDEF check for FETCH_DIM_R and family --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 52e4f5bc35..d95b3b4939 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1797,6 +1797,8 @@ try_string_offset: } zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim)); break; + case IS_UNDEF: + zval_undefined_cv(EG(current_execute_data)->opline->op2.var, EG(current_execute_data)); case IS_DOUBLE: case IS_NULL: case IS_FALSE: @@ -1813,7 +1815,7 @@ try_string_offset: break; } - offset = zval_get_long(dim); + offset = _zval_get_long_func(dim); } else { offset = Z_LVAL_P(dim); } @@ -1840,6 +1842,10 @@ try_string_offset: } } } else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { + if (/*dim_type == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) { + zval_undefined_cv(EG(current_execute_data)->opline->op2.var, EG(current_execute_data)); + dim = &EG(uninitialized_zval); + } if (!Z_OBJ_HT_P(container)->read_dimension) { zend_throw_error(NULL, "Cannot use object as array"); ZVAL_NULL(result); @@ -1856,6 +1862,12 @@ try_string_offset: } } } else { + if (type != BP_VAR_IS && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) { + zval_undefined_cv(EG(current_execute_data)->opline->op1.var, EG(current_execute_data)); + } + if (/*dim_type == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) { + zval_undefined_cv(EG(current_execute_data)->opline->op2.var, EG(current_execute_data)); + } ZVAL_NULL(result); } } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 1710ba44dd..06a0f75386 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -747,6 +747,7 @@ static zend_always_inline zend_long ZEND_FASTCALL _zval_get_long_func_ex(zval *o { try_again: switch (Z_TYPE_P(op)) { + case IS_UNDEF: case IS_NULL: case IS_FALSE: return 0; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index ad77fe0c57..0e3c3cbeb0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1690,8 +1690,8 @@ ZEND_VM_HANDLER(81, ZEND_FETCH_DIM_R, CONST|TMPVAR|CV, CONST|TMPVAR|CV) zval *container; SAVE_OPLINE(); - container = GET_OP1_ZVAL_PTR(BP_VAR_R); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE); + container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE); FREE_OP2(); FREE_OP1(); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -1740,8 +1740,8 @@ ZEND_VM_HANDLER(90, ZEND_FETCH_DIM_IS, CONST|TMPVAR|CV, CONST|TMPVAR|CV) zval *container; SAVE_OPLINE(); - container = GET_OP1_ZVAL_PTR(BP_VAR_IS); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE); + container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_IS); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE); FREE_OP2(); FREE_OP1(); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -1776,8 +1776,8 @@ ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUS FREE_UNFETCHED_OP1(); HANDLE_EXCEPTION(); } - container = GET_OP1_ZVAL_PTR(BP_VAR_R); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE); + container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE); FREE_OP2(); FREE_OP1(); } @@ -2069,8 +2069,8 @@ ZEND_VM_HANDLER(98, ZEND_FETCH_LIST, CONST|TMPVAR|CV, CONST|TMPVAR|CV) zval *container; SAVE_OPLINE(); - container = GET_OP1_ZVAL_PTR(BP_VAR_R); - zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR(BP_VAR_R)); + container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); + zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R)); FREE_OP2(); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 2b8cb15eac..a6ebb3a578 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -8816,7 +8816,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CONST_CV_HAND SAVE_OPLINE(); container = EX_CONSTANT(opline->op1); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -8830,7 +8830,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CONST_CV_HAN SAVE_OPLINE(); container = EX_CONSTANT(opline->op1); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -8866,7 +8866,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CONST_ HANDLE_EXCEPTION(); } container = EX_CONSTANT(opline->op1); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); } @@ -9062,7 +9062,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CONST_CV_HANDL SAVE_OPLINE(); container = EX_CONSTANT(opline->op1); - zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var)); + zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -14337,7 +14337,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_TMP_CV HANDLE_EXCEPTION(); } container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); zval_ptr_dtor_nogc(free_op1); } @@ -22014,7 +22014,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_VAR_CV HANDLE_EXCEPTION(); } container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); zval_ptr_dtor_nogc(free_op1); } @@ -37323,7 +37323,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_CONST_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, EX_CONSTANT(opline->op2), IS_CONST); @@ -37373,7 +37373,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_CONST_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, EX_CONSTANT(opline->op2), IS_CONST); @@ -37409,7 +37409,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CON HANDLE_EXCEPTION(); } - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, EX_CONSTANT(opline->op2), IS_CONST); @@ -37700,7 +37700,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CV_CONST_HANDL zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, EX_CONSTANT(opline->op2)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -41507,7 +41507,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_UNU HANDLE_EXCEPTION(); } - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, NULL, IS_UNUSED); @@ -43742,8 +43742,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_CV_HANDLER zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -43792,8 +43792,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_CV_HANDLE zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -43828,8 +43828,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_CV_ HANDLE_EXCEPTION(); } - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); } @@ -44119,8 +44119,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CV_CV_HANDLER( zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); - zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var)); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); + zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -47335,7 +47335,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_CV_TMPVAR_HAN zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2), (IS_TMP_VAR|IS_VAR)); zval_ptr_dtor_nogc(free_op2); @@ -47385,7 +47385,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_CV_TMPVAR_HA zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_IS(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2), (IS_TMP_VAR|IS_VAR)); zval_ptr_dtor_nogc(free_op2); @@ -47421,7 +47421,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_FUNC_ARG_SPEC_CV_TMP HANDLE_EXCEPTION(); } - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2), (IS_TMP_VAR|IS_VAR)); zval_ptr_dtor_nogc(free_op2); @@ -47714,7 +47714,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CV_TMPVAR_HAND zval *container; SAVE_OPLINE(); - container = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var); + container = _get_zval_ptr_cv_undef(execute_data, opline->op1.var); zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2)); zval_ptr_dtor_nogc(free_op2); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -53131,7 +53131,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_SPEC_TMPVAR_CV_HAN SAVE_OPLINE(); container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); - zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); zval_ptr_dtor_nogc(free_op1); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -53145,7 +53145,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_IS_SPEC_TMPVAR_CV_HA SAVE_OPLINE(); container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); - zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var), IS_CV); + zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var), IS_CV); zval_ptr_dtor_nogc(free_op1); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -53231,7 +53231,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_TMPVAR_CV_HAND SAVE_OPLINE(); container = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1); - zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var)); + zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, _get_zval_ptr_cv_undef(execute_data, opline->op2.var)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); }