summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-03-10 11:43:25 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-03-10 11:43:25 +0900
commite8f09f93930e0c99769e4e4ded2342638ac3d5e5 (patch)
treeef1493ccb2c66bb5546cc1641358c0f427fd2a4f /src/class.c
parentc6e5659fec42b1c2ac39292a1ba2ee5852c66846 (diff)
downloadmruby-e8f09f93930e0c99769e4e4ded2342638ac3d5e5.tar.gz
mruby-e8f09f93930e0c99769e4e4ded2342638ac3d5e5.zip
Raise special Exception when exception class is redefined; fix #3493
Diffstat (limited to 'src/class.c')
-rw-r--r--src/class.c10
1 files changed, 8 insertions, 2 deletions
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)