@@ -3234,10 +3234,6 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
3234
3234
/* Create and initialize output hash */
3235
3235
zend_hash_init (& out_hash , (length > 0 ? num_in - length : 0 ) + (replace ? zend_hash_num_elements (replace ) : 0 ), NULL , ZVAL_PTR_DTOR , 0 );
3236
3236
3237
- if (length > ZEND_LONG_MAX - offset || length < ZEND_LONG_MIN + offset ) {
3238
- goto end ;
3239
- }
3240
-
3241
3237
if (HT_IS_PACKED (in_hash )) {
3242
3238
/* Start at the beginning of the input hash and copy entries to output hash until offset is reached */
3243
3239
entry = in_hash -> arPacked ;
@@ -3256,7 +3252,7 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
3256
3252
3257
3253
/* If hash for removed entries exists, go until offset+length and copy the entries to it */
3258
3254
if (removed != NULL ) {
3259
- for ( ; pos < offset + length && idx < in_hash -> nNumUsed ; idx ++ , entry ++ ) {
3255
+ for ( ; pos - offset < length && idx < in_hash -> nNumUsed ; idx ++ , entry ++ ) {
3260
3256
if (Z_TYPE_P (entry ) == IS_UNDEF ) continue ;
3261
3257
pos ++ ;
3262
3258
Z_TRY_ADDREF_P (entry );
@@ -3266,7 +3262,7 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
3266
3262
} else { /* otherwise just skip those entries */
3267
3263
zend_long pos2 = pos ;
3268
3264
3269
- for ( ; pos2 < offset + length && idx < in_hash -> nNumUsed ; idx ++ , entry ++ ) {
3265
+ for ( ; pos2 - offset < length && idx < in_hash -> nNumUsed ; idx ++ , entry ++ ) {
3270
3266
if (Z_TYPE_P (entry ) == IS_UNDEF ) continue ;
3271
3267
pos2 ++ ;
3272
3268
zend_hash_packed_del_val (in_hash , entry );
@@ -3321,7 +3317,7 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
3321
3317
3322
3318
/* If hash for removed entries exists, go until offset+length and copy the entries to it */
3323
3319
if (removed != NULL ) {
3324
- for ( ; pos < offset + length && idx < in_hash -> nNumUsed ; idx ++ , p ++ ) {
3320
+ for ( ; pos - offset < length && idx < in_hash -> nNumUsed ; idx ++ , p ++ ) {
3325
3321
if (Z_TYPE (p -> val ) == IS_UNDEF ) continue ;
3326
3322
pos ++ ;
3327
3323
entry = & p -> val ;
@@ -3334,9 +3330,9 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
3334
3330
zend_hash_del_bucket (in_hash , p );
3335
3331
}
3336
3332
} else { /* otherwise just skip those entries */
3337
- int pos2 = pos ;
3333
+ zend_long pos2 = pos ;
3338
3334
3339
- for ( ; pos2 < offset + length && idx < in_hash -> nNumUsed ; idx ++ , p ++ ) {
3335
+ for ( ; pos2 - offset < length && idx < in_hash -> nNumUsed ; idx ++ , p ++ ) {
3340
3336
if (Z_TYPE (p -> val ) == IS_UNDEF ) continue ;
3341
3337
pos2 ++ ;
3342
3338
zend_hash_del_bucket (in_hash , p );
@@ -3372,7 +3368,6 @@ static void php_splice(HashTable *in_hash, zend_long offset, zend_long length, H
3372
3368
}
3373
3369
}
3374
3370
3375
- end :
3376
3371
/* replace HashTable data */
3377
3372
HT_SET_ITERATORS_COUNT (& out_hash , HT_ITERATORS_COUNT (in_hash ));
3378
3373
HT_SET_ITERATORS_COUNT (in_hash , 0 );
0 commit comments