@@ -180,7 +180,7 @@ ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_
180
180
ht -> nNumUsed = 0 ;
181
181
ht -> nNumOfElements = 0 ;
182
182
ht -> nInternalPointer = HT_INVALID_IDX ;
183
- ht -> nNextFreeElement = 0 ;
183
+ ht -> nNextFreeElement = ZEND_LONG_MIN ;
184
184
ht -> pDestructor = pDestructor ;
185
185
ht -> nTableSize = zend_hash_check_size (nSize );
186
186
}
@@ -795,8 +795,8 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht,
795
795
ZEND_HASH_IF_FULL_DO_RESIZE (ht ); /* If the Hash table is full, resize it */
796
796
797
797
add_to_hash :
798
- /* If the first index is negative, dont force the next index to be 0 */
799
- if (UNEXPECTED (( zend_long ) h < 0 && ht -> nNumOfElements == 0 ) ) {
798
+ /* Initialize nNextFreeElement with the value of the first numeric index */
799
+ if (ht -> nNextFreeElement == ZEND_LONG_MIN ) {
800
800
ht -> nNextFreeElement = h ;
801
801
}
802
802
idx = ht -> nNumUsed ++ ;
@@ -1400,7 +1400,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht)
1400
1400
}
1401
1401
ht -> nNumUsed = 0 ;
1402
1402
ht -> nNumOfElements = 0 ;
1403
- ht -> nNextFreeElement = 0 ;
1403
+ ht -> nNextFreeElement = ZEND_LONG_MIN ;
1404
1404
ht -> nInternalPointer = HT_INVALID_IDX ;
1405
1405
}
1406
1406
@@ -1439,7 +1439,7 @@ ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht)
1439
1439
}
1440
1440
ht -> nNumUsed = 0 ;
1441
1441
ht -> nNumOfElements = 0 ;
1442
- ht -> nNextFreeElement = 0 ;
1442
+ ht -> nNextFreeElement = ZEND_LONG_MIN ;
1443
1443
ht -> nInternalPointer = HT_INVALID_IDX ;
1444
1444
}
1445
1445
@@ -1776,7 +1776,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
1776
1776
target -> nTableMask = HT_MIN_MASK ;
1777
1777
target -> nNumUsed = 0 ;
1778
1778
target -> nNumOfElements = 0 ;
1779
- target -> nNextFreeElement = 0 ;
1779
+ target -> nNextFreeElement = ZEND_LONG_MIN ;
1780
1780
target -> nInternalPointer = HT_INVALID_IDX ;
1781
1781
HT_SET_DATA_ADDR (target , & uninitialized_bucket );
1782
1782
} else if (GC_FLAGS (source ) & IS_ARRAY_IMMUTABLE ) {
0 commit comments