summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-12 09:46:38 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-10-12 09:46:38 +0200
commitd953cd18621709f115b1cf5ba93e75769a532d9e (patch)
treed33de099642e367b5b4352b523cbb7cad5c501c6
parentfbf221cac45b31dc4a963b33cf558f3929d6ab10 (diff)
parent304141e8f8e810875ef18fabaefde6ded5929aa0 (diff)
downloadphp-git-d953cd18621709f115b1cf5ba93e75769a532d9e.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Avoid non-object in FE_FREE
-rw-r--r--Zend/zend_vm_def.h13
-rw-r--r--Zend/zend_vm_execute.h52
2 files changed, 40 insertions, 25 deletions
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 930cd342e8..d647dddeab 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -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));
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index e180c28c75..27d1ee1571 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -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));
}