class.c: add `obj->c` check before `prepare_singleton_class()`.

parent 475b868b
......@@ -357,6 +357,7 @@ prepare_singleton_class(mrb_state *mrb, struct RBasic *o)
{
struct RClass *sc, *c;
mrb_assert(o->c);
if (o->c->tt == MRB_TT_SCLASS) return;
sc = MRB_OBJ_ALLOC(mrb, MRB_TT_SCLASS, mrb->class_class);
sc->flags |= MRB_FL_CLASS_IS_INHERITED;
......@@ -1682,6 +1683,7 @@ mrb_singleton_class_ptr(mrb_state *mrb, mrb_value v)
break;
}
obj = mrb_basic_ptr(v);
if (obj->c == NULL) return NULL;
prepare_singleton_class(mrb, obj);
return obj->c;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment