singleton_class should not be cloned; close #2815

This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-06-01 00:13:12 +09:00
parent c80f500c68
commit bd2686d82d
+3
View File
@@ -330,6 +330,9 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
if (mrb_immediate_p(self)) {
mrb_raisef(mrb, E_TYPE_ERROR, "can't clone %S", self);
}
if (mrb_type(self) == MRB_TT_SCLASS) {
mrb_raise(mrb, E_TYPE_ERROR, "can't clone singleton class");
}
p = (struct RObject*)mrb_obj_alloc(mrb, mrb_type(self), mrb_obj_class(mrb, self));
p->c = mrb_singleton_class_clone(mrb, self);
clone = mrb_obj_value(p);