summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-02-11 01:53:01 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-02-11 01:53:01 +0000
commit9dc45d57a9216877b08d137c07effd664b49bda8 (patch)
tree33ac9994f4f40d48d1560a559675c726edf2c9aa /regcomp.c
parent4865a36daa1b2556054c8fc5515c6d3ea3656997 (diff)
downloadperl-9dc45d57a9216877b08d137c07effd664b49bda8.tar.gz
"Can't happen" - yes, it can, with buggy UTF-8/EBCDIC.
Stepping backward in the string would be majorly bad. p4raw-id: //depot/perl@14633
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/regcomp.c b/regcomp.c
index 7850492497..7e1e6bd6d5 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -3188,16 +3188,22 @@ tryagain:
foldlen;
foldlen -= numlen) {
ender = utf8_to_uvchr(foldbuf, &numlen);
- reguni(pRExC_state, ender, s, &numlen);
- s += numlen;
- len += numlen;
- foldbuf += numlen;
+ if (numlen > 0) {
+ reguni(pRExC_state, ender, s, &numlen);
+ s += numlen;
+ len += numlen;
+ foldbuf += numlen;
+ }
+ else
+ break; /* "Can't happen." */
}
}
else {
reguni(pRExC_state, ender, s, &numlen);
- s += numlen;
- len += numlen;
+ if (numlen > 0) {
+ s += numlen;
+ len += numlen;
+ }
}
}
else {
@@ -3213,16 +3219,22 @@ tryagain:
foldlen;
foldlen -= numlen) {
ender = utf8_to_uvchr(foldbuf, &numlen);
- reguni(pRExC_state, ender, s, &numlen);
- s += numlen;
- len += numlen;
- foldbuf += numlen;
+ if (numlen > 0) {
+ reguni(pRExC_state, ender, s, &numlen);
+ s += numlen;
+ len += numlen;
+ foldbuf += numlen;
+ }
+ else
+ break;
}
}
else {
reguni(pRExC_state, ender, s, &numlen);
- s += numlen;
- len += numlen;
+ if (numlen > 0) {
+ s += numlen;
+ len += numlen;
+ }
}
len--;
}