Skip to content

Commit 1005f92

Browse files
committed
Use slot API during cloning
Otherwise we can probably run into the same issues here as we could with destruction.
1 parent bb3e82b commit 1005f92

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Zend/zend_objects.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,12 @@ ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object,
204204
i_zval_ptr_dtor(dst);
205205
ZVAL_COPY_VALUE(dst, src);
206206
zval_add_ref(dst);
207-
if (UNEXPECTED(Z_ISREF_P(dst))) {
208-
zend_property_info *prop_info;
209-
ZEND_REF_FOREACH_TYPE_SOURCES(Z_REF_P(dst), prop_info) {
210-
if (prop_info->ce == new_object->ce && dst == OBJ_PROP(new_object, prop_info->offset)) {
211-
ZEND_REF_ADD_TYPE_SOURCE(Z_REF_P(dst), prop_info);
212-
break; /* stop iteration here, the array might be realloc()'ed */
213-
}
214-
} ZEND_REF_FOREACH_TYPE_SOURCES_END();
207+
if (UNEXPECTED(Z_ISREF_P(dst)) &&
208+
(ZEND_DEBUG || ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(dst)))) {
209+
zend_property_info *prop_info = zend_get_property_info_for_slot(new_object, dst);
210+
if (prop_info->type) {
211+
ZEND_REF_ADD_TYPE_SOURCE(Z_REF_P(dst), prop_info);
212+
}
215213
}
216214
src++;
217215
dst++;

0 commit comments

Comments
 (0)