summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-12-26 12:49:24 +0000
committerDavid Mitchell <davem@iabyn.com>2016-12-26 12:49:24 +0000
commitd720149d59afad1fa0ae15d5f092fdc47bd1a4f7 (patch)
tree0ed8e2693265e5871d4672ae5a4412ee3f82b32f /pp.c
parent6b776407d46448d59a69054c8cd4cec4d91f50c0 (diff)
downloadperl-d720149d59afad1fa0ae15d5f092fdc47bd1a4f7.tar.gz
split ' ', $foo: don't check end byte
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="".
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/pp.c b/pp.c
index 300d786421..c015bfe8a6 100644
--- 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++;
}
}