@@ -3592,7 +3592,7 @@ static zend_always_inline void i_zval_ptr_dtor_noref(zval *zval_ptr) {
3592
3592
}
3593
3593
}
3594
3594
3595
- ZEND_API zval * zend_assign_to_typed_ref (zval * variable_ptr , zval * orig_value , uint8_t value_type , bool strict )
3595
+ 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 )
3596
3596
{
3597
3597
bool ret ;
3598
3598
zval value ;
@@ -3607,7 +3607,9 @@ ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, ui
3607
3607
ret = zend_verify_ref_assignable_zval (Z_REF_P (variable_ptr ), & value , strict );
3608
3608
variable_ptr = Z_REFVAL_P (variable_ptr );
3609
3609
if (EXPECTED (ret )) {
3610
- i_zval_ptr_dtor_noref (variable_ptr );
3610
+ if (Z_REFCOUNTED_P (variable_ptr )) {
3611
+ * garbage_ptr = Z_COUNTED_P (variable_ptr );
3612
+ }
3611
3613
ZVAL_COPY_VALUE (variable_ptr , & value );
3612
3614
} else {
3613
3615
zval_ptr_dtor_nogc (& value );
@@ -3625,6 +3627,20 @@ ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, ui
3625
3627
return variable_ptr ;
3626
3628
}
3627
3629
3630
+ ZEND_API zval * zend_assign_to_typed_ref (zval * variable_ptr , zval * orig_value , uint8_t value_type , bool strict )
3631
+ {
3632
+ zend_refcounted * garbage = NULL ;
3633
+ zval * result = zend_assign_to_typed_ref_ex (variable_ptr , orig_value , value_type , strict , & garbage );
3634
+ if (garbage ) {
3635
+ if (GC_DELREF (garbage ) == 0 ) {
3636
+ rc_dtor_func (garbage );
3637
+ } else {
3638
+ gc_check_possible_root_no_ref (garbage );
3639
+ }
3640
+ }
3641
+ return result ;
3642
+ }
3643
+
3628
3644
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 ) {
3629
3645
zval * val = orig_val ;
3630
3646
if (Z_ISREF_P (val ) && ZEND_REF_HAS_TYPE_SOURCES (Z_REF_P (val ))) {
0 commit comments