diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-04 20:50:54 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-09-04 20:50:54 +0900 |
| commit | 7592dfcf7dfabc5d5df26906d6571d4f61aa8de7 (patch) | |
| tree | bc9328dd4e894dd4cc01fca716111d63317d9650 | |
| parent | c2634e18b6dc8bf2b447e6f18699e3f4ed6f9474 (diff) | |
| download | mruby-7592dfcf7dfabc5d5df26906d6571d4f61aa8de7.tar.gz mruby-7592dfcf7dfabc5d5df26906d6571d4f61aa8de7.zip | |
Need more precise constant name check.
This change was inspired by [ruby-bugs#7573]
| -rw-r--r-- | src/class.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c index e074cbc3b..22fe36fb3 100644 --- a/src/class.c +++ b/src/class.c @@ -1981,7 +1981,14 @@ mrb_mod_const_get(mrb_state *mrb, mrb_value mod) end = (end == -1) ? len : end; id = mrb_intern(mrb, ptr+off, end-off); mod = mrb_const_get_sym(mrb, mod, id); - off = (end == len) ? end : end+2; + if (end == len) + off = end; + else { + off = end + 2; + if (off == len) { /* trailing "::" */ + mrb_name_error(mrb, id, "wrong constant name '%S'", path); + } + } } return mod; |
