summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-14 08:30:54 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-14 08:30:54 +0000
commit6a3931e0f630f56d4acd2b232f58c0225f03f52b (patch)
treefe8a957b8513962866aa7beefb4ffc5498a70a4a /string.c
parent9681409e3691037c11c19052295616454f74c936 (diff)
Check pos and strlen on Regexp#index(str, pos) [ruby-core:23660]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/string.c b/string.c
index 9418bfe2ca..493ef5d87b 100644
--- a/string.c
+++ b/string.c
@@ -2569,6 +2569,8 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
switch (TYPE(sub)) {
case T_REGEXP:
+ if (pos > str_strlen(str, STR_ENC_GET(str)))
+ return Qnil;
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
rb_enc_check(str, sub), single_byte_optimizable(str));