@@ -1044,7 +1044,8 @@ ZEND_VM_C_LABEL(assign_op_object):
10441044
10451045 // if this is a data class, we may need to CoW
10461046 if (zobj -> ce -> ce_flags & ZEND_ACC_DATA_CLASS ) {
1047- if (GC_REFCOUNT (zobj ) > 1 ) {
1047+ // skip if in a constructor or if the object is not shared
1048+ if (!(EX (func )-> common .fn_flags & ZEND_ACC_CTOR ) && GC_REFCOUNT (zobj ) > 1 ) {
10481049 // clone the object
10491050 zend_object * new_obj = zend_objects_clone_obj (zobj );
10501051 // set the object zval to the new object
@@ -1326,7 +1327,8 @@ ZEND_VM_C_LABEL(pre_incdec_object):
13261327
13271328 // if this is a data class, we may need to CoW
13281329 if (zobj -> ce -> ce_flags & ZEND_ACC_DATA_CLASS ) {
1329- if (GC_REFCOUNT (zobj ) > 1 ) {
1330+ // skip if in a constructor or if the object is not shared
1331+ if (!(EX (func )-> common .fn_flags & ZEND_ACC_CTOR ) && GC_REFCOUNT (zobj ) > 1 ) {
13301332 // clone the object
13311333 zend_object * new_obj = zend_objects_clone_obj (zobj );
13321334 // set the object zval to the new object
@@ -1409,7 +1411,8 @@ ZEND_VM_C_LABEL(post_incdec_object):
14091411
14101412 // if this is a data class, we may need to CoW
14111413 if (zobj -> ce -> ce_flags & ZEND_ACC_DATA_CLASS ) {
1412- if (GC_REFCOUNT (zobj ) > 1 ) {
1414+ // skip if in a constructor or if the object is not shared
1415+ if (!(EX (func )-> common .fn_flags & ZEND_ACC_CTOR ) && GC_REFCOUNT (zobj ) > 1 ) {
14131416 // clone the object
14141417 zend_object * new_obj = zend_objects_clone_obj (zobj );
14151418 // set the object zval to the new object
@@ -2601,11 +2604,8 @@ ZEND_VM_C_LABEL(fast_assign_obj):
26012604
26022605 // if this is a data class, we may need to CoW
26032606 if (zobj -> ce -> ce_flags & ZEND_ACC_DATA_CLASS ) {
2604- // skip if in a constructor
2605- if (EX (func )-> common .fn_flags & ZEND_ACC_CTOR ) {
2606- // skip
2607- } else
2608- if (GC_REFCOUNT (zobj ) > 1 ) {
2607+ // skip if in a constructor or if the object is not shared
2608+ if (!(EX (func )-> common .fn_flags & ZEND_ACC_CTOR ) && GC_REFCOUNT (zobj ) > 1 ) {
26092609 // clone the object
26102610 zend_object * new_obj = zend_objects_clone_obj (zobj );
26112611 // set the object zval to the new object
@@ -6866,7 +6866,8 @@ ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, CACHE_S
68666866 // if this is a data class, we may need to CoW
68676867 zend_object * zobj = Z_OBJ_P (container );
68686868 if (zobj -> ce -> ce_flags & ZEND_ACC_DATA_CLASS ) {
6869- if (GC_REFCOUNT (zobj ) > 1 ) {
6869+ // skip if in a constructor or if the object is not shared
6870+ if (!(EX (func )-> common .fn_flags & ZEND_ACC_CTOR ) && GC_REFCOUNT (zobj ) > 1 ) {
68706871 // clone the object
68716872 zend_object * new_obj = zend_objects_clone_obj (zobj );
68726873 // set the object zval to the new object
0 commit comments