@@ -377,7 +377,7 @@ static zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_object *
377
377
{
378
378
/* we have to return NULL on error here to avoid memleak because of
379
379
* ZE duplicating uninitialized_zval_ptr */
380
- if (!offset ) {
380
+ if (UNEXPECTED ( !offset ) ) {
381
381
zend_throw_error (NULL , "[] operator not supported for SplFixedArray" );
382
382
return NULL ;
383
383
}
@@ -422,7 +422,7 @@ static zval *spl_fixedarray_object_read_dimension(zend_object *object, zval *off
422
422
423
423
static void spl_fixedarray_object_write_dimension_helper (spl_fixedarray_object * intern , zval * offset , zval * value )
424
424
{
425
- if (!offset ) {
425
+ if (UNEXPECTED ( !offset ) ) {
426
426
/* '$array[] = value' syntax is not supported */
427
427
zend_throw_error (NULL , "[] operator not supported for SplFixedArray" );
428
428
return ;
@@ -438,10 +438,10 @@ static void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_object *
438
438
} else {
439
439
/* Fix #81429 */
440
440
zval * ptr = & (intern -> array .elements [index ]);
441
- zval tmp ;
442
- ZVAL_COPY_VALUE ( & tmp , ptr );
443
- ZVAL_COPY_DEREF ( ptr , value );
444
- zval_ptr_dtor ( & tmp );
441
+ /* This should be guaranteed by the VM handler or argument parsing. */
442
+ ZEND_ASSERT ( Z_TYPE_P ( value ) != IS_REFERENCE );
443
+ Z_TRY_ADDREF_P ( value );
444
+ zend_safe_assign_to_variable_noref ( ptr , value );
445
445
}
446
446
}
447
447
@@ -472,10 +472,9 @@ static void spl_fixedarray_object_unset_dimension_helper(spl_fixedarray_object *
472
472
if (UNEXPECTED (index >= intern -> array .size )) {
473
473
zend_throw_exception (spl_ce_OutOfBoundsException , "Index invalid or out of range" , 0 );
474
474
} else {
475
- zval garbage ;
476
- ZVAL_COPY_VALUE (& garbage , & intern -> array .elements [index ]);
477
- ZVAL_NULL (& intern -> array .elements [index ]);
478
- zval_ptr_dtor (& garbage );
475
+ zval null = {0 };
476
+ ZVAL_NULL (& null );
477
+ zend_safe_assign_to_variable_noref (& intern -> array .elements [index ], & null );
479
478
}
480
479
}
481
480
0 commit comments