summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-09-04 20:50:54 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-09-04 20:50:54 +0900
commit7592dfcf7dfabc5d5df26906d6571d4f61aa8de7 (patch)
treebc9328dd4e894dd4cc01fca716111d63317d9650 /src
parentc2634e18b6dc8bf2b447e6f18699e3f4ed6f9474 (diff)
downloadmruby-7592dfcf7dfabc5d5df26906d6571d4f61aa8de7.tar.gz
mruby-7592dfcf7dfabc5d5df26906d6571d4f61aa8de7.zip
Need more precise constant name check.
This change was inspired by [ruby-bugs#7573]
Diffstat (limited to 'src')
-rw-r--r--src/class.c9
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;