mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add type check for cls before allocation
This commit is contained in:
@@ -480,7 +480,18 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls)
|
||||
mrb_gc *gc = &mrb->gc;
|
||||
|
||||
if (cls) {
|
||||
enum mrb_vtype tt = MRB_INSTANCE_TT(cls);
|
||||
enum mrb_vtype tt;
|
||||
|
||||
switch (cls->tt) {
|
||||
case MRB_TT_CLASS:
|
||||
case MRB_TT_SCLASS:
|
||||
case MRB_TT_MODULE:
|
||||
case MRB_TT_ENV:
|
||||
break;
|
||||
default:
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "allocation failure");
|
||||
}
|
||||
tt = MRB_INSTANCE_TT(cls);
|
||||
if (tt != MRB_TT_FALSE &&
|
||||
ttype != MRB_TT_SCLASS &&
|
||||
ttype != MRB_TT_ICLASS &&
|
||||
|
||||
Reference in New Issue
Block a user