diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-06-01 00:13:12 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-06-01 00:13:12 +0900 |
| commit | bd2686d82d233774003fe683e9396f366b152b6d (patch) | |
| tree | 05750509da21fbeb96e5e23dd89a4537ac4f5445 | |
| parent | c80f500c68de24e114e4a7437db61ebfca7918f8 (diff) | |
| download | mruby-bd2686d82d233774003fe683e9396f366b152b6d.tar.gz mruby-bd2686d82d233774003fe683e9396f366b152b6d.zip | |
singleton_class should not be cloned; close #2815
| -rw-r--r-- | src/kernel.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/kernel.c b/src/kernel.c index d1e10a7f8..9d056178e 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -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); |
