Skip to content

Commit 90cf654

Browse files
author
Andi Gutmans
committed
- Fix for crash bug when using invalid arguments in the foreach() loop.
- Reported by Yasuo Ohgaki
1 parent fb39bda commit 90cf654

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Zend/zend_execute.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,9 +2141,13 @@ binary_assign_op_addr: {
21412141

21422142
if (opline->extended_value) {
21432143
array_ptr_ptr = get_zval_ptr_ptr(&opline->op1, Ts, BP_VAR_R);
2144-
SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);
2145-
array_ptr = *array_ptr_ptr;
2146-
array_ptr->refcount++;
2144+
if (array_ptr_ptr == NULL) {
2145+
MAKE_STD_ZVAL(array_ptr);
2146+
} else {
2147+
SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);
2148+
array_ptr = *array_ptr_ptr;
2149+
array_ptr->refcount++;
2150+
}
21472151
} else {
21482152
array_ptr = get_zval_ptr(&opline->op1, Ts, &EG(free_op1), BP_VAR_R);
21492153
if (EG(free_op1)) { /* IS_TMP_VAR */

0 commit comments

Comments
 (0)