summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index b06c2f5b8..aaf14468a 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;