From 9d1b64c781f526fb32724e0f05acde6496a9d50e Mon Sep 17 00:00:00 2001 From: yugui Date: Wed, 15 Jul 2009 12:01:14 +0000 Subject: merges r24103 from trunk into ruby_1_9_1. -- Check pos and strlen on Regexp#index(str, pos) [ruby-core:23660] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'string.c') diff --git a/string.c b/string.c index bf719b8ee..c27e5d486 100644 --- a/string.c +++ b/string.c @@ -2378,6 +2378,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)); -- cgit