@@ -3711,6 +3711,19 @@ static void get_unlinked_dependency(zend_class_entry *ce, const char **kind, con
3711
3711
}
3712
3712
}
3713
3713
3714
+ static zend_result preload_update_constant (zval * val , zend_class_entry * scope )
3715
+ {
3716
+ zval tmp ;
3717
+ ZVAL_COPY (& tmp , val );
3718
+ if (zval_update_constant_ex (& tmp , scope ) == FAILURE || Z_TYPE (tmp ) == IS_OBJECT ) {
3719
+ zval_ptr_dtor (& tmp );
3720
+ return FAILURE ;
3721
+ }
3722
+ zval_ptr_dtor_nogc (val );
3723
+ ZVAL_COPY_VALUE (val , & tmp );
3724
+ return SUCCESS ;
3725
+ }
3726
+
3714
3727
static bool preload_try_resolve_constants (zend_class_entry * ce )
3715
3728
{
3716
3729
bool ok , changed , was_changed = 0 ;
@@ -3724,7 +3737,7 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
3724
3737
ZEND_HASH_FOREACH_PTR (& ce -> constants_table , c ) {
3725
3738
val = & c -> value ;
3726
3739
if (Z_TYPE_P (val ) == IS_CONSTANT_AST ) {
3727
- if (EXPECTED (zval_update_constant_ex (val , c -> ce ) == SUCCESS )) {
3740
+ if (EXPECTED (preload_update_constant (val , c -> ce ) == SUCCESS )) {
3728
3741
was_changed = changed = 1 ;
3729
3742
} else {
3730
3743
ok = 0 ;
@@ -3742,7 +3755,7 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
3742
3755
val = & ce -> default_properties_table [i ];
3743
3756
if (Z_TYPE_P (val ) == IS_CONSTANT_AST ) {
3744
3757
zend_property_info * prop = ce -> properties_info_table [i ];
3745
- if (UNEXPECTED (zval_update_constant_ex (val , prop -> ce ) != SUCCESS )) {
3758
+ if (UNEXPECTED (preload_update_constant (val , prop -> ce ) != SUCCESS )) {
3746
3759
resolved = ok = 0 ;
3747
3760
}
3748
3761
}
@@ -3758,7 +3771,7 @@ static bool preload_try_resolve_constants(zend_class_entry *ce)
3758
3771
val = ce -> default_static_members_table + ce -> default_static_members_count - 1 ;
3759
3772
while (count ) {
3760
3773
if (Z_TYPE_P (val ) == IS_CONSTANT_AST ) {
3761
- if (UNEXPECTED (zval_update_constant_ex (val , ce ) != SUCCESS )) {
3774
+ if (UNEXPECTED (preload_update_constant (val , ce ) != SUCCESS )) {
3762
3775
resolved = ok = 0 ;
3763
3776
}
3764
3777
}
0 commit comments