@@ -960,25 +960,27 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
960960uninit_error :
961961 if (UNEXPECTED (zend_lazy_object_must_init (zobj ))) {
962962 if (!prop_info || (Z_PROP_FLAG_P (retval ) & IS_PROP_LAZY )) {
963- zobj = zend_lazy_object_init (zobj );
964- if (!zobj ) {
963+ zend_object * instance = zend_lazy_object_init (zobj );
964+ if (!instance ) {
965965 retval = & EG (uninitialized_zval );
966966 goto exit ;
967967 }
968968
969- if (UNEXPECTED (guard )) {
969+ if (UNEXPECTED (guard && (instance -> ce -> ce_flags & ZEND_ACC_USE_GUARDS ))) {
970+ /* Find which guard was used on zobj, so we can set the same
971+ * guard on instance. */
970972 uint32_t guard_type = (type == BP_VAR_IS ) && zobj -> ce -> __isset
971973 ? IN_ISSET : IN_GET ;
972- guard = zend_get_property_guard (zobj , name );
974+ guard = zend_get_property_guard (instance , name );
973975 if (!((* guard ) & guard_type )) {
974976 (* guard ) |= guard_type ;
975- retval = zend_std_read_property (zobj , name , type , cache_slot , rv );
977+ retval = zend_std_read_property (instance , name , type , cache_slot , rv );
976978 (* guard ) &= ~guard_type ;
977979 return retval ;
978980 }
979981 }
980982
981- return zend_std_read_property (zobj , name , type , cache_slot , rv );
983+ return zend_std_read_property (instance , name , type , cache_slot , rv );
982984 }
983985 }
984986 if (type != BP_VAR_IS ) {
@@ -1017,7 +1019,7 @@ static zval *forward_write_to_lazy_object(zend_object *zobj,
10171019 return & EG (error_zval );
10181020 }
10191021
1020- if (UNEXPECTED (guarded )) {
1022+ if (UNEXPECTED (guarded && ( instance -> ce -> ce_flags & ZEND_ACC_USE_GUARDS ) )) {
10211023 uint32_t * guard = zend_get_property_guard (instance , name );
10221024 if (!((* guard ) & IN_SET )) {
10231025 (* guard ) |= IN_SET ;
@@ -1601,7 +1603,7 @@ ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void
16011603 return ;
16021604 }
16031605
1604- if (UNEXPECTED (guard )) {
1606+ if (UNEXPECTED (guard && zobj -> ce -> ce_flags & ZEND_ACC_USE_GUARDS )) {
16051607 guard = zend_get_property_guard (zobj , name );
16061608 if (!((* guard ) & IN_UNSET )) {
16071609 (* guard ) |= IN_UNSET ;
0 commit comments