The special-cased code to skip spaces at the start of the string
didn't check that s < strend, so relied on the string being \0-terminated
to work correctly. The introduction of the isSPACE_utf8_safe() macro
showed up this dodgy assumption by causing assert failures in regen.t
under LC_ALL=en_US.UTF-8 PERL_UNICODE="".
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++;
}
}
set_up_inc('../lib');
}
-plan tests => 161;
+plan tests => 162;
$FS = ':';
ok eval { $a[0] = 'a'; 1; }, "array split filling AvARRAY: assign 0";
is "@a", "a b", "array split filling AvARRAY: result";
}
+
+# splitting an empty utf8 string gave an assert failure
+{
+ my $s = "\x{100}";
+ chop $s;
+ my @a = split ' ', $s;
+ is (+@a, 0, "empty utf8 string");
+}