summaryrefslogtreecommitdiff
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 161c8a9894..5b60e9268b 100644
--- a/string.c
+++ b/string.c
@@ -2631,7 +2631,7 @@ rb_str_each_line(argc, argv, str)
if (*++p != '\n') continue;
while (*p == '\n') p++;
}
- if (p[-1] == newline &&
+ if (RSTRING(str)->ptr < p && p[-1] == newline &&
(rslen <= 1 ||
rb_memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) {
line = rb_str_new5(str, s, p - s);