Skip to content

Commit e8f09f9

Browse files
committed
Raise special Exception when exception class is redefined; fix #3493
1 parent c6e5659 commit e8f09f9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: src/class.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,14 @@ mrb_class_get(mrb_state *mrb, const char *name)
330330
MRB_API struct RClass *
331331
mrb_exc_get(mrb_state *mrb, const char *name)
332332
{
333-
struct RClass *exc = mrb_class_get_under(mrb, mrb->object_class, name);
334-
struct RClass *e = exc;
333+
struct RClass *exc, *e;
334+
mrb_value c = mrb_const_get(mrb, mrb_obj_value(mrb->object_class),
335+
mrb_intern_cstr(mrb, name));
336+
337+
if (mrb_type(c) != MRB_TT_CLASS) {
338+
mrb_raise(mrb, mrb->eException_class, "exception corrupted");
339+
}
340+
exc = e = mrb_class_ptr(c);
335341

336342
while (e) {
337343
if (e == mrb->eException_class)

0 commit comments

Comments
 (0)