Skip to content

Commit bd0f111

Browse files
committed
Stricter type tag in mrb_obj_alloc()
Instances cannot be created with `MRB_TT_FALSE`. _**Compatibility Note**_ This change may cause runtime errors. However, that is probably because it is not set correctly by `MRB_SET_INSTANCE_TT()`.
1 parent 8b20f34 commit bd0f111

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/gc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,12 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls)
482482
mrb_raise(mrb, E_TYPE_ERROR, "allocation failure");
483483
}
484484
tt = MRB_INSTANCE_TT(cls);
485-
if (tt != MRB_TT_FALSE &&
486-
ttype != MRB_TT_SCLASS &&
485+
if (ttype != MRB_TT_SCLASS &&
487486
ttype != MRB_TT_ICLASS &&
488487
ttype != MRB_TT_ENV &&
489488
ttype != MRB_TT_BIGINT &&
490-
ttype != tt) {
489+
ttype != tt &&
490+
!(cls == mrb->object_class && (ttype == MRB_TT_CPTR || ttype == MRB_TT_CDATA || ttype == MRB_TT_ISTRUCT))) {
491491
mrb_raisef(mrb, E_TYPE_ERROR, "allocation failure of %C", cls);
492492
}
493493
}

0 commit comments

Comments
 (0)