summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-11-30 10:36:17 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2016-11-30 10:36:17 +0900
commit2bb47addadb3eda796520837c21d694c8d6e3320 (patch)
tree57c57252d89435e42f78ad94381f449c517d5a52 /src/class.c
parentf7c0024b8ed4b48e8e6f58df8a9865dcc424a5b0 (diff)
downloadmruby-2bb47addadb3eda796520837c21d694c8d6e3320.tar.gz
mruby-2bb47addadb3eda796520837c21d694c8d6e3320.zip
Prohibit instantiation of immediate objects
Diffstat (limited to 'src/class.c')
-rw-r--r--src/class.c3
1 files changed, 3 insertions, 0 deletions
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);
}