Skip to content

Commit 22c0913

Browse files
committed
rb_copy_generic_ivar: reset shape_id when no ivar are present
1 parent 1e33a45 commit 22c0913

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

object.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,12 @@ init_copy(VALUE dest, VALUE obj)
409409
RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR);
410410
// Copies the shape id from obj to dest
411411
RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR);
412-
rb_copy_generic_ivar(dest, obj);
413412
if (RB_TYPE_P(obj, T_OBJECT)) {
414413
rb_obj_copy_ivar(dest, obj);
415414
}
415+
else {
416+
rb_copy_generic_ivar(dest, obj);
417+
}
416418
rb_gc_copy_attributes(dest, obj);
417419
}
418420

variable.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,9 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
24382438

24392439
clear:
24402440
if (FL_TEST(dest, FL_EXIVAR)) {
2441+
#if SHAPE_IN_BASIC_FLAGS
2442+
RBASIC_SET_SHAPE_ID(dest, ROOT_SHAPE_ID);
2443+
#endif
24412444
rb_free_generic_ivar(dest);
24422445
FL_UNSET(dest, FL_EXIVAR);
24432446
}

0 commit comments

Comments
 (0)