Permalink
Browse files

Fixed a bug that make a loop in singleton_class clone; fix #3687

  • Loading branch information...
matz committed Jun 2, 2017
1 parent 31e3068 commit a8bf3742c6af24563c5888ef783c9c41041d7400
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/kernel.c
View
@@ -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) {

0 comments on commit a8bf374

Please sign in to comment.