This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
split ' ', $foo: don't check end byte
[perl5.git] / pp.c
diff --git a/pp.c b/pp.c
index 300d786..c015bfe 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -5794,15 +5794,15 @@ PP(pp_split)
     orig = s;
     if (RX_EXTFLAGS(rx) & RXf_SKIPWHITE) {
        if (do_utf8) {
-           while (isSPACE_utf8_safe(s, strend))
+           while (s < strend && isSPACE_utf8_safe(s, strend))
                s += UTF8SKIP(s);
        }
        else if (get_regex_charset(RX_EXTFLAGS(rx)) == REGEX_LOCALE_CHARSET) {
-           while (isSPACE_LC(*s))
+           while (s < strend && isSPACE_LC(*s))
                s++;
        }
        else {
-           while (isSPACE(*s))
+           while (s < strend && isSPACE(*s))
                s++;
        }
     }