Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Avoid non-object in FE_FREE
This commit is contained in:
Nikita Popov 2020-10-12 09:46:38 +02:00
commit d953cd1862
2 changed files with 40 additions and 25 deletions

View File

@ -6496,15 +6496,18 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET_R, CONST|TMP|VAR|CV, JMP_ADDR)
properties = zobj->handlers->get_properties(zobj);
}
if (zend_hash_num_elements(properties) == 0) {
ZEND_VM_C_GOTO(fe_reset_r_empty);
}
result = EX_VAR(opline->result.var);
ZVAL_COPY_VALUE(result, array_ptr);
if (OP1_TYPE != IS_TMP_VAR) {
Z_ADDREF_P(array_ptr);
}
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(result) = (uint32_t) -1;
FREE_OP1_IF_VAR();
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
Z_FE_ITER_P(result) = zend_hash_iterator_add(properties, 0);
FREE_OP1_IF_VAR();
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
@ -6522,7 +6525,6 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET_R, CONST|TMP|VAR|CV, JMP_ADDR)
}
} else {
zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_type_name(array_ptr));
ZEND_VM_C_LABEL(fe_reset_r_empty):
ZVAL_UNDEF(EX_VAR(opline->result.var));
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
FREE_OP1();
@ -6595,6 +6597,7 @@ ZEND_VM_COLD_CONST_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
properties = Z_OBJPROP_P(array_ptr);
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t) -1;
FREE_OP1_VAR_PTR();
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}

View File

@ -4805,15 +4805,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CONST_HANDLER(
properties = zobj->handlers->get_properties(zobj);
}
if (zend_hash_num_elements(properties) == 0) {
goto fe_reset_r_empty;
}
result = EX_VAR(opline->result.var);
ZVAL_COPY_VALUE(result, array_ptr);
if (IS_CONST != IS_TMP_VAR) {
Z_ADDREF_P(array_ptr);
}
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(result) = (uint32_t) -1;
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
Z_FE_ITER_P(result) = zend_hash_iterator_add(properties, 0);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
@ -4830,7 +4833,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CONST_HANDLER(
}
} else {
zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_type_name(array_ptr));
fe_reset_r_empty:
ZVAL_UNDEF(EX_VAR(opline->result.var));
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
@ -4903,6 +4905,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_
properties = Z_OBJPROP_P(array_ptr);
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t) -1;
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
@ -18812,15 +18815,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_TMP_HANDLER(ZE
properties = zobj->handlers->get_properties(zobj);
}
if (zend_hash_num_elements(properties) == 0) {
goto fe_reset_r_empty;
}
result = EX_VAR(opline->result.var);
ZVAL_COPY_VALUE(result, array_ptr);
if (IS_TMP_VAR != IS_TMP_VAR) {
Z_ADDREF_P(array_ptr);
}
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(result) = (uint32_t) -1;
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
Z_FE_ITER_P(result) = zend_hash_iterator_add(properties, 0);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
@ -18838,7 +18844,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_TMP_HANDLER(ZE
}
} else {
zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_type_name(array_ptr));
fe_reset_r_empty:
ZVAL_UNDEF(EX_VAR(opline->result.var));
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
@ -18911,6 +18916,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_TMP_HANDLER(Z
properties = Z_OBJPROP_P(array_ptr);
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t) -1;
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
@ -21374,15 +21380,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_VAR_HANDLER(ZE
properties = zobj->handlers->get_properties(zobj);
}
if (zend_hash_num_elements(properties) == 0) {
goto fe_reset_r_empty;
}
result = EX_VAR(opline->result.var);
ZVAL_COPY_VALUE(result, array_ptr);
if (IS_VAR != IS_TMP_VAR) {
Z_ADDREF_P(array_ptr);
}
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(result) = (uint32_t) -1;
zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
Z_FE_ITER_P(result) = zend_hash_iterator_add(properties, 0);
zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
@ -21400,7 +21409,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_VAR_HANDLER(ZE
}
} else {
zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_type_name(array_ptr));
fe_reset_r_empty:
ZVAL_UNDEF(EX_VAR(opline->result.var));
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
@ -21473,6 +21481,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_VAR_HANDLER(Z
properties = Z_OBJPROP_P(array_ptr);
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t) -1;
zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
@ -38086,15 +38095,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CV_HANDLER(ZEN
properties = zobj->handlers->get_properties(zobj);
}
if (zend_hash_num_elements(properties) == 0) {
goto fe_reset_r_empty;
}
result = EX_VAR(opline->result.var);
ZVAL_COPY_VALUE(result, array_ptr);
if (IS_CV != IS_TMP_VAR) {
Z_ADDREF_P(array_ptr);
}
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(result) = (uint32_t) -1;
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}
Z_FE_ITER_P(result) = zend_hash_iterator_add(properties, 0);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
@ -38111,7 +38123,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CV_HANDLER(ZEN
}
} else {
zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_type_name(array_ptr));
fe_reset_r_empty:
ZVAL_UNDEF(EX_VAR(opline->result.var));
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
@ -38184,6 +38195,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_RW_SPEC_CV_HANDLER(ZE
properties = Z_OBJPROP_P(array_ptr);
if (zend_hash_num_elements(properties) == 0) {
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t) -1;
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
}