Skip to content

Instantly share code, notes, and snippets.

@wanabe
Created July 12, 2013 13:26
Show Gist options
  • Select an option

  • Save wanabe/5984443 to your computer and use it in GitHub Desktop.

Select an option

Save wanabe/5984443 to your computer and use it in GitHub Desktop.
diff --git a/src/class.c b/src/class.c
index a50d3d8..9080265 100644
--- a/src/class.c
+++ b/src/class.c
@@ -78,8 +78,14 @@ prepare_singleton_class(mrb_state *mrb, struct RBasic *o)
}
else if (o->tt == MRB_TT_SCLASS) {
c = (struct RClass*)o;
- make_metaclass(mrb, c->super);
- sc->super = c->super->c;
+ while (c->tt != MRB_TT_CLASS) {
+ c = c->super;
+ if (!c) {
+ mrb_bug(mrb, "corrupted class chain!");
+ }
+ }
+ make_metaclass(mrb, c);
+ sc->super = c->c;
}
else {
sc->super = o->c;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment