Need more precise constant name check.

This change was inspired by [ruby-bugs#7573]
This commit is contained in:
Yukihiro "Matz" Matsumoto
2018-09-04 20:50:54 +09:00
parent c2634e18b6
commit 7592dfcf7d
+8 -1
View File
@@ -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;