summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-01-11 09:53:31 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-01-11 10:29:55 +0900
commit44edc51612536a9e23dabf7c87afc3996efde027 (patch)
treedbdd85a7db3ffdc398095fdf0ff591f634ba2148 /src/class.c
parent7523cdf3404230213cb858f38bd91135d478a7f3 (diff)
downloadmruby-44edc51612536a9e23dabf7c87afc3996efde027.tar.gz
mruby-44edc51612536a9e23dabf7c87afc3996efde027.zip
Raises Exception if raising exception class is redefined
close #3384 This issue was reported by https://hackerone.com/brakhane
Diffstat (limited to 'src/class.c')
-rw-r--r--src/class.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/class.c b/src/class.c
index fed259b5b..cb7bdfddd 100644
--- a/src/class.c
+++ b/src/class.c
@@ -318,6 +318,20 @@ 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;
+
+ while (e) {
+ if (e == mrb->eException_class)
+ return exc;
+ e = e->super;
+ }
+ return mrb->eException_class;
+}
+
+MRB_API struct RClass *
mrb_module_get_under(mrb_state *mrb, struct RClass *outer, const char *name)
{
return module_from_sym(mrb, outer, mrb_intern_cstr(mrb, name));