diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-01-11 09:53:31 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-01-11 10:29:55 +0900 |
| commit | 44edc51612536a9e23dabf7c87afc3996efde027 (patch) | |
| tree | dbdd85a7db3ffdc398095fdf0ff591f634ba2148 /src/class.c | |
| parent | 7523cdf3404230213cb858f38bd91135d478a7f3 (diff) | |
| download | mruby-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.c | 14 |
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)); |
