Commit fe3fe8fc authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3615 from clayton-shopify/fix-copy-class-null-pointer-deref

Check if sc->mt is initialized before copying it.
parents 79e03143 de969942
......@@ -241,7 +241,12 @@ copy_class(mrb_state *mrb, mrb_value dst, mrb_value src)
c1->super = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(c0)));
c1->super->flags |= MRB_FLAG_IS_ORIGIN;
}
dc->mt = kh_copy(mt, mrb, sc->mt);
if (sc->mt) {
dc->mt = kh_copy(mt, mrb, sc->mt);
}
else {
dc->mt = kh_init(mt, mrb);
}
dc->super = sc->super;
MRB_SET_INSTANCE_TT(dc, MRB_INSTANCE_TT(sc));
}
......
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