summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-20 05:43:27 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-20 05:43:27 +0000
commit88014987ad8e159594ac44dd4444078af75c1394 (patch)
treec696bd040ab053347957e050ebd71a74ccd23d1d
parent2cc02aeb500909616d3757f52f0e40d5380de79f (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--ChangeLog5
-rw-r--r--string.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fa373a7a8..987fda39f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/string.c b/string.c
index 798e108d42..1f02ebff49 100644
--- a/string.c
+++ b/string.c
@@ -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);