@@ -3589,7 +3589,7 @@ static zend_always_inline void i_zval_ptr_dtor_noref(zval *zval_ptr) {
3589
3589
}
3590
3590
}
3591
3591
3592
- ZEND_API zval * zend_assign_to_typed_ref (zval * variable_ptr , zval * orig_value , uint8_t value_type , bool strict )
3592
+ ZEND_API zval * zend_assign_to_typed_ref_ex (zval * variable_ptr , zval * orig_value , uint8_t value_type , bool strict , zend_refcounted * * garbage_ptr )
3593
3593
{
3594
3594
bool ret ;
3595
3595
zval value ;
@@ -3604,7 +3604,9 @@ ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, ui
3604
3604
ret = zend_verify_ref_assignable_zval (Z_REF_P (variable_ptr ), & value , strict );
3605
3605
variable_ptr = Z_REFVAL_P (variable_ptr );
3606
3606
if (EXPECTED (ret )) {
3607
- i_zval_ptr_dtor_noref (variable_ptr );
3607
+ if (Z_REFCOUNTED_P (variable_ptr )) {
3608
+ * garbage_ptr = Z_COUNTED_P (variable_ptr );
3609
+ }
3608
3610
ZVAL_COPY_VALUE (variable_ptr , & value );
3609
3611
} else {
3610
3612
zval_ptr_dtor_nogc (& value );
@@ -3622,6 +3624,20 @@ ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, ui
3622
3624
return variable_ptr ;
3623
3625
}
3624
3626
3627
+ ZEND_API zval * zend_assign_to_typed_ref (zval * variable_ptr , zval * orig_value , uint8_t value_type , bool strict )
3628
+ {
3629
+ zend_refcounted * garbage = NULL ;
3630
+ zval * result = zend_assign_to_typed_ref_ex (variable_ptr , orig_value , value_type , strict , & garbage );
3631
+ if (garbage ) {
3632
+ if (GC_DELREF (garbage ) == 0 ) {
3633
+ rc_dtor_func (garbage );
3634
+ } else {
3635
+ gc_check_possible_root_no_ref (garbage );
3636
+ }
3637
+ }
3638
+ return result ;
3639
+ }
3640
+
3625
3641
ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref_ex (const zend_property_info * prop_info , zval * orig_val , bool strict , zend_verify_prop_assignable_by_ref_context context ) {
3626
3642
zval * val = orig_val ;
3627
3643
if (Z_ISREF_P (val ) && ZEND_REF_HAS_TYPE_SOURCES (Z_REF_P (val ))) {
0 commit comments