rb_copy_generic_ivar: reset shape_id when no ivar are present

This commit is contained in:
Jean Boussier 2025-05-16 16:08:21 +02:00
parent 1e33a451bb
commit 22c09135a8
Notes: git 2025-05-16 18:17:05 +00:00
2 changed files with 6 additions and 1 deletions

View File

@ -409,10 +409,12 @@ init_copy(VALUE dest, VALUE obj)
RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR);
// Copies the shape id from obj to dest
RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR);
rb_copy_generic_ivar(dest, obj);
if (RB_TYPE_P(obj, T_OBJECT)) {
rb_obj_copy_ivar(dest, obj);
}
else {
rb_copy_generic_ivar(dest, obj);
}
rb_gc_copy_attributes(dest, obj);
}

View File

@ -2438,6 +2438,9 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
clear:
if (FL_TEST(dest, FL_EXIVAR)) {
#if SHAPE_IN_BASIC_FLAGS
RBASIC_SET_SHAPE_ID(dest, ROOT_SHAPE_ID);
#endif
rb_free_generic_ivar(dest);
FL_UNSET(dest, FL_EXIVAR);
}