Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
class.c: add obj->c check before prepare_singleton_class().
  • Loading branch information
matz committed Jan 16, 2022
1 parent 475b868 commit 31fa330
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/class.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 31fa330

Please sign in to comment.