summaryrefslogtreecommitdiffhomepage
path: root/src/kernel.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-06-02 13:25:15 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-06-02 13:25:15 +0900
commita8bf3742c6af24563c5888ef783c9c41041d7400 (patch)
tree09045f0ab32afc0efffee41a0c6d84bc16f3f0a4 /src/kernel.c
parent31e30686b0bd9333eb0593fb1fb43b9b99744517 (diff)
downloadmruby-a8bf3742c6af24563c5888ef783c9c41041d7400.tar.gz
mruby-a8bf3742c6af24563c5888ef783c9c41041d7400.zip
Fixed a bug that make a loop in singleton_class clone; fix #3687
Diffstat (limited to 'src/kernel.c')
-rw-r--r--src/kernel.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/kernel.c b/src/kernel.c
index f0a5ed536..20f52922d 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -199,11 +199,13 @@ mrb_singleton_class_clone(mrb_state *mrb, mrb_value obj)
/* copy singleton(unnamed) class */
struct RClass *clone = (struct RClass*)mrb_obj_alloc(mrb, klass->tt, mrb->class_class);
- if ((mrb_type(obj) == MRB_TT_CLASS) || (mrb_type(obj) == MRB_TT_SCLASS)) {
- clone->c = clone;
- }
- else {
+ switch (mrb_type(obj)) {
+ case MRB_TT_CLASS:
+ case MRB_TT_SCLASS:
+ break;
+ default:
clone->c = mrb_singleton_class_clone(mrb, mrb_obj_value(klass));
+ break;
}
clone->super = klass->super;
if (klass->iv) {