[前][次][番号順一覧][スレッド一覧]

ruby-changes:12404

From: naruse <ko1@a...>
Date: Tue, 14 Jul 2009 17:31:45 +0900 (JST)
Subject: [ruby-changes:12404] Ruby:r24103 (trunk): Check pos and strlen on Regexp#index(str, pos)

naruse	2009-07-14 17:30:54 +0900 (Tue, 14 Jul 2009)

  New Revision: 24103

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24103

  Log:
    Check pos and strlen on Regexp#index(str, pos) [ruby-core:23660]

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24102)
+++ ChangeLog	(revision 24103)
@@ -1,3 +1,8 @@
+Tue Jul 14 17:29:20 2009  NARUSE, Yui  <naruse@r...>
+
+	* string.c (rb_str_index_m): return nil if pos is out of string.
+	  [ruby-core:23660]
+
 Tue Jul 14 16:13:04 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (rb_io_initialize): check if the descriptor can be accessed
Index: string.c
===================================================================
--- string.c	(revision 24102)
+++ string.c	(revision 24103)
@@ -2569,6 +2569,8 @@
 
     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));
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]