aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/object.c b/object.c
index 13765bc621..b385135019 100644
--- a/object.c
+++ b/object.c
@@ -1959,7 +1959,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
rb_raise(rb_eNameError, "wrong constant name %s", path);
}
- if (p[0] == ':' && p[1] == ':') {
+ if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
mod = rb_cObject;
p += 2;
pbeg = p;
@@ -1981,8 +1981,8 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
else {
part = rb_str_subseq(name, pbeg-path, p-pbeg);
}
- if (p[0] == ':') {
- if (p[1] != ':') {
+ if (p < pend && p[0] == ':') {
+ if (p + 2 >= pend || p[1] != ':') {
rb_raise(rb_eNameError, "wrong constant name %s", path);
}
p += 2;