@@ -554,13 +554,15 @@ static void spl_array_unset_dimension_ex(int check_inherited, zend_object *objec
554
554
if (Z_TYPE_P (data ) == IS_INDIRECT ) {
555
555
data = Z_INDIRECT_P (data );
556
556
if (Z_TYPE_P (data ) != IS_UNDEF ) {
557
- zval_ptr_dtor (data );
557
+ zval garbage ;
558
+ ZVAL_COPY_VALUE (& garbage , data );
558
559
ZVAL_UNDEF (data );
559
560
HT_FLAGS (ht ) |= HASH_FLAG_HAS_EMPTY_IND ;
560
561
zend_hash_move_forward_ex (ht , spl_array_get_pos_ptr (ht , intern ));
561
562
if (spl_array_is_object (intern )) {
562
563
spl_array_skip_protected (intern , ht );
563
564
}
565
+ zval_ptr_dtor (& garbage );
564
566
}
565
567
} else {
566
568
zend_hash_del (ht , key .key );
@@ -1051,8 +1053,10 @@ static HashTable *spl_array_it_get_gc(zend_object_iterator *iter, zval **table,
1051
1053
static void spl_array_set_array (zval * object , spl_array_object * intern , zval * array , zend_long ar_flags , bool just_array ) {
1052
1054
/* Handled by ZPP prior to this, or for __unserialize() before passing to here */
1053
1055
ZEND_ASSERT (Z_TYPE_P (array ) == IS_ARRAY || Z_TYPE_P (array ) == IS_OBJECT );
1056
+ zval garbage ;
1057
+ ZVAL_UNDEF (& garbage );
1054
1058
if (Z_TYPE_P (array ) == IS_ARRAY ) {
1055
- zval_ptr_dtor ( & intern -> array );
1059
+ ZVAL_COPY_VALUE ( & garbage , & intern -> array );
1056
1060
if (Z_REFCOUNT_P (array ) == 1 ) {
1057
1061
ZVAL_COPY (& intern -> array , array );
1058
1062
} else {
@@ -1070,7 +1074,7 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
1070
1074
}
1071
1075
} else {
1072
1076
if (Z_OBJ_HT_P (array ) == & spl_handler_ArrayObject || Z_OBJ_HT_P (array ) == & spl_handler_ArrayIterator ) {
1073
- zval_ptr_dtor ( & intern -> array );
1077
+ ZVAL_COPY_VALUE ( & garbage , & intern -> array );
1074
1078
if (just_array ) {
1075
1079
spl_array_object * other = Z_SPLARRAY_P (array );
1076
1080
ar_flags = other -> ar_flags & ~SPL_ARRAY_INT_MASK ;
@@ -1088,9 +1092,10 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
1088
1092
zend_throw_exception_ex (spl_ce_InvalidArgumentException , 0 ,
1089
1093
"Overloaded object of type %s is not compatible with %s" ,
1090
1094
ZSTR_VAL (Z_OBJCE_P (array )-> name ), ZSTR_VAL (intern -> std .ce -> name ));
1095
+ ZEND_ASSERT (Z_TYPE (garbage ) == IS_UNDEF );
1091
1096
return ;
1092
1097
}
1093
- zval_ptr_dtor ( & intern -> array );
1098
+ ZVAL_COPY_VALUE ( & garbage , & intern -> array );
1094
1099
ZVAL_COPY (& intern -> array , array );
1095
1100
}
1096
1101
}
@@ -1101,6 +1106,8 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
1101
1106
zend_hash_iterator_del (intern -> ht_iter );
1102
1107
intern -> ht_iter = (uint32_t )-1 ;
1103
1108
}
1109
+
1110
+ zval_ptr_dtor (& garbage );
1104
1111
}
1105
1112
/* }}} */
1106
1113
0 commit comments