diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-19 10:34:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-19 10:34:13 +0000 |
commit | c3026b723c4af4be56e3297a29d5a21b5d64eecc (patch) | |
tree | 500872e0d05c193ba3c921ff44ba91a5f1869d9a /object.c | |
parent | 542a12d673ee5da8a7b8d40d66415f3e72bb0077 (diff) |
object.c: nul in const name
* object.c (rb_mod_const_get): nul byte is invalid as constant name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1920,7 +1920,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) { VALUE name, recur; rb_encoding *enc; - const char *pbeg, *p, *path; + const char *pbeg, *p, *path, *pend; ID id; if (argc == 1) { @@ -1946,6 +1946,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) } pbeg = p = path; + pend = path + RSTRING_LEN(name); if (!*p) { rb_raise(rb_eNameError, "wrong constant name %s", path); @@ -1957,10 +1958,10 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) pbeg = p; } - while (*p) { + while (p < pend) { VALUE part; - while (*p && *p != ':') p++; + while (p < pend && *p != ':') p++; if (pbeg == p) { rb_raise(rb_eNameError, "wrong constant name %s", path); |