From e8f09f93930e0c99769e4e4ded2342638ac3d5e5 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 10 Mar 2017 11:43:25 +0900 Subject: Raise special Exception when exception class is redefined; fix #3493 --- src/class.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/class.c b/src/class.c index 0922b3cff..fdb10d271 100644 --- a/src/class.c +++ b/src/class.c @@ -330,8 +330,14 @@ mrb_class_get(mrb_state *mrb, const char *name) MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name) { - struct RClass *exc = mrb_class_get_under(mrb, mrb->object_class, name); - struct RClass *e = exc; + struct RClass *exc, *e; + mrb_value c = mrb_const_get(mrb, mrb_obj_value(mrb->object_class), + mrb_intern_cstr(mrb, name)); + + if (mrb_type(c) != MRB_TT_CLASS) { + mrb_raise(mrb, mrb->eException_class, "exception corrupted"); + } + exc = e = mrb_class_ptr(c); while (e) { if (e == mrb->eException_class) -- cgit v1.2.3