aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 09:28:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 09:28:31 +0000
commit0eb5c917e06561a0ce8957702d21c93ec803216f (patch)
tree0d7c10e36e3aff4b05cf4c253f06d4060b9c530d
parentead329fd8ea6f0ecf11c6ec98e073eed6fe2810c (diff)
downloadruby-0eb5c917e06561a0ce8957702d21c93ec803216f.tar.gz
* string.c (rb_str_each_line): don't call rb_enc_codepoint with empty
string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ad26d83687..5e0eba52d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec 25 18:27:51 2007 Tanaka Akira <akr@fsij.org>
+
+ * string.c (rb_str_each_line): don't call rb_enc_codepoint with empty
+ string.
+
Tue Dec 25 18:06:04 2007 Tanaka Akira <akr@fsij.org>
* string.c (rb_str_inspect): don't call rb_enc_codepoint with empty
diff --git a/string.c b/string.c
index b06c2f5b8f..aaf14468af 100644
--- a/string.c
+++ b/string.c
@@ -4310,7 +4310,7 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
int n = rb_enc_codelen(c, enc);
if (rslen == 0 && c == newline) {
- while (rb_enc_codepoint(p, pend, enc) == newline) {
+ while (p < pend && rb_enc_codepoint(p, pend, enc) == newline) {
p += n;
}
p -= n;