From 2bb47addadb3eda796520837c21d694c8d6e3320 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 30 Nov 2016 10:36:17 +0900 Subject: Prohibit instantiation of immediate objects --- src/class.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/class.c') diff --git a/src/class.c b/src/class.c index d120f1fec..bac1d2984 100644 --- a/src/class.c +++ b/src/class.c @@ -1348,6 +1348,9 @@ mrb_instance_alloc(mrb_state *mrb, mrb_value cv) mrb_raise(mrb, E_TYPE_ERROR, "can't create instance of singleton class"); if (ttype == 0) ttype = MRB_TT_OBJECT; + if (ttype <= MRB_TT_CPTR) { + mrb_raisef(mrb, E_TYPE_ERROR, "can't create instance of %S", cv); + } o = (struct RObject*)mrb_obj_alloc(mrb, ttype, c); return mrb_obj_value(o); } -- cgit v1.2.3