@@ -40,6 +40,7 @@ PHPAPI zend_class_entry *spl_ce_ArrayObject;
4040
4141typedef struct _spl_array_object {
4242 zval array ;
43+ HashTable * sentinel_array ;
4344 uint32_t ht_iter ;
4445 int ar_flags ;
4546 unsigned char nApplyCount ;
@@ -79,11 +80,14 @@ static inline HashTable **spl_array_get_hash_table_ptr(spl_array_object* intern)
7980 if (UNEXPECTED (zend_lazy_object_must_init (obj ))) {
8081 obj = zend_lazy_object_init (obj );
8182 if (UNEXPECTED (!obj )) {
82- zval_ptr_dtor (& intern -> array );
83- ZVAL_ARR (& intern -> array , zend_new_array (0 ));
84- return & Z_ARRVAL (intern -> array );
83+ if (!intern -> sentinel_array ) {
84+ intern -> sentinel_array = zend_new_array (0 );
85+ }
86+ return & intern -> sentinel_array ;
8587 }
8688 }
89+ /* should no longer be lazy */
90+ ZEND_ASSERT (!zend_lazy_object_must_init (obj ));
8791 /* rebuild properties */
8892 zend_std_get_properties_ex (obj );
8993 if (GC_REFCOUNT (obj -> properties ) > 1 ) {
@@ -139,6 +143,10 @@ static void spl_array_object_free_storage(zend_object *object)
139143 zend_hash_iterator_del (intern -> ht_iter );
140144 }
141145
146+ if (UNEXPECTED (intern -> sentinel_array )) {
147+ zend_array_release (intern -> sentinel_array );
148+ }
149+
142150 zend_object_std_dtor (& intern -> std );
143151
144152 zval_ptr_dtor (& intern -> array );
@@ -499,6 +507,9 @@ static void spl_array_write_dimension_ex(int check_inherited, zend_object *objec
499507 uint32_t refcount = 0 ;
500508 if (!offset || Z_TYPE_P (offset ) == IS_NULL ) {
501509 ht = spl_array_get_hash_table (intern );
510+ if (UNEXPECTED (ht == intern -> sentinel_array )) {
511+ return ;
512+ }
502513 refcount = spl_array_set_refcount (intern -> is_child , ht , 1 );
503514 zend_hash_next_index_insert (ht , value );
504515
@@ -515,6 +526,10 @@ static void spl_array_write_dimension_ex(int check_inherited, zend_object *objec
515526 }
516527
517528 ht = spl_array_get_hash_table (intern );
529+ if (UNEXPECTED (ht == intern -> sentinel_array )) {
530+ spl_hash_key_release (& key );
531+ return ;
532+ }
518533 refcount = spl_array_set_refcount (intern -> is_child , ht , 1 );
519534 if (key .key ) {
520535 zend_hash_update_ind (ht , key .key , value );
0 commit comments