diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-20 05:43:27 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-20 05:43:27 +0000 |
commit | 88014987ad8e159594ac44dd4444078af75c1394 (patch) | |
tree | c696bd040ab053347957e050ebd71a74ccd23d1d | |
parent | 2cc02aeb500909616d3757f52f0e40d5380de79f (diff) |
* string.c (rb_str_each_line): check string's length when compare
separator and string. [ruby-core:35815] fixes #4586
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | string.c | 3 |
2 files changed, 7 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Wed Apr 20 14:41:28 2011 NARUSE, Yui <naruse@ruby-lang.org> + + * string.c (rb_str_each_line): check string's length when compare + separator and string. [ruby-core:35815] fixes #4586 + Wed Apr 20 00:02:13 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> * misc/ruby-mode.el (ruby-parse-partial): use position of open paren. @@ -6051,7 +6051,8 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str) p -= n; } if (c == newline && - (rslen <= 1 || memcmp(RSTRING_PTR(rs), p, rslen) == 0)) { + (rslen <= 1 || + (pend - p >= rslen && memcmp(RSTRING_PTR(rs), p, rslen) == 0))) { line = rb_str_new5(str, s, p - s + (rslen ? rslen : n)); OBJ_INFECT(line, str); rb_enc_cr_str_copy_for_substr(line, str); |