@@ -993,11 +993,9 @@ static HashTable *spl_array_it_get_gc(zend_object_iterator *iter, zval **table,
993
993
}
994
994
995
995
/* {{{ spl_array_set_array */
996
- static void spl_array_set_array (zval * object , spl_array_object * intern , zval * array , zend_long ar_flags , int just_array ) {
997
- if (Z_TYPE_P (array ) != IS_OBJECT && Z_TYPE_P (array ) != IS_ARRAY ) {
998
- zend_throw_exception (spl_ce_InvalidArgumentException , "Passed variable is not an array or object" , 0 );
999
- return ;
1000
- }
996
+ static void spl_array_set_array (zval * object , spl_array_object * intern , zval * array , zend_long ar_flags , bool just_array ) {
997
+ /* Handled by ZPP prior to this, or for __unserialize() before passing to here */
998
+ ZEND_ASSERT (Z_TYPE_P (array ) == IS_ARRAY || Z_TYPE_P (array ) == IS_OBJECT );
1001
999
if (Z_TYPE_P (array ) == IS_ARRAY ) {
1002
1000
zval_ptr_dtor (& intern -> array );
1003
1001
if (Z_REFCOUNT_P (array ) == 1 ) {
@@ -1739,6 +1737,11 @@ PHP_METHOD(ArrayObject, __unserialize)
1739
1737
zval_ptr_dtor (& intern -> array );
1740
1738
ZVAL_UNDEF (& intern -> array );
1741
1739
} else {
1740
+ if (Z_TYPE_P (storage_zv ) != IS_OBJECT && Z_TYPE_P (storage_zv ) != IS_ARRAY ) {
1741
+ /* TODO Use UnexpectedValueException instead? And better error message? */
1742
+ zend_throw_exception (spl_ce_InvalidArgumentException , "Passed variable is not an array or object" , 0 );
1743
+ RETURN_THROWS ();
1744
+ }
1742
1745
spl_array_set_array (ZEND_THIS , intern , storage_zv , 0L , 1 );
1743
1746
}
1744
1747
0 commit comments