@@ -1054,8 +1054,10 @@ static HashTable *spl_array_it_get_gc(zend_object_iterator *iter, zval **table,
1054
1054
static void spl_array_set_array (zval * object , spl_array_object * intern , zval * array , zend_long ar_flags , bool just_array ) {
1055
1055
/* Handled by ZPP prior to this, or for __unserialize() before passing to here */
1056
1056
ZEND_ASSERT (Z_TYPE_P (array ) == IS_ARRAY || Z_TYPE_P (array ) == IS_OBJECT );
1057
+ zval garbage ;
1058
+ ZVAL_UNDEF (& garbage );
1057
1059
if (Z_TYPE_P (array ) == IS_ARRAY ) {
1058
- zval_ptr_dtor ( & intern -> array );
1060
+ ZVAL_COPY_VALUE ( & garbage , & intern -> array );
1059
1061
if (Z_REFCOUNT_P (array ) == 1 ) {
1060
1062
ZVAL_COPY (& intern -> array , array );
1061
1063
} else {
@@ -1073,7 +1075,7 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
1073
1075
}
1074
1076
} else {
1075
1077
if (Z_OBJ_HT_P (array ) == & spl_handler_ArrayObject || Z_OBJ_HT_P (array ) == & spl_handler_ArrayIterator ) {
1076
- zval_ptr_dtor ( & intern -> array );
1078
+ ZVAL_COPY_VALUE ( & garbage , & intern -> array );
1077
1079
if (just_array ) {
1078
1080
spl_array_object * other = Z_SPLARRAY_P (array );
1079
1081
ar_flags = other -> ar_flags & ~SPL_ARRAY_INT_MASK ;
@@ -1091,9 +1093,10 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
1091
1093
zend_throw_exception_ex (spl_ce_InvalidArgumentException , 0 ,
1092
1094
"Overloaded object of type %s is not compatible with %s" ,
1093
1095
ZSTR_VAL (Z_OBJCE_P (array )-> name ), ZSTR_VAL (intern -> std .ce -> name ));
1096
+ ZEND_ASSERT (Z_TYPE (garbage ) == IS_UNDEF );
1094
1097
return ;
1095
1098
}
1096
- zval_ptr_dtor ( & intern -> array );
1099
+ ZVAL_COPY_VALUE ( & garbage , & intern -> array );
1097
1100
ZVAL_COPY (& intern -> array , array );
1098
1101
}
1099
1102
}
@@ -1104,6 +1107,8 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
1104
1107
zend_hash_iterator_del (intern -> ht_iter );
1105
1108
intern -> ht_iter = (uint32_t )-1 ;
1106
1109
}
1110
+
1111
+ zval_ptr_dtor (& garbage );
1107
1112
}
1108
1113
/* }}} */
1109
1114
0 commit comments