summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorKarl <khw@karl.(none)>2008-12-26 10:45:05 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-12-28 15:36:26 +0100
commit3f0c5693d0a2100faf1b56983c7325096fcb0bda (patch)
tree6f5683e0a6fba04de67b2714204b74f429916a1a /regexec.c
parent3cf20fa2fb953d611f6cc722b308008b48536e07 (diff)
downloadperl-3f0c5693d0a2100faf1b56983c7325096fcb0bda.tar.gz
Fix malformed utf8 in regexec.c
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/regexec.c b/regexec.c
index f959121b81..94d67618fb 100644
--- a/regexec.c
+++ b/regexec.c
@@ -5771,7 +5771,14 @@ S_reginclass(pTHX_ const regexp *prog, register const regnode *n, register const
SV * const sw = regclass_swash(prog, n, TRUE, 0, (SV**)&av);
if (sw) {
- if (swash_fetch(sw, p, do_utf8))
+ U8 * utf8_p;
+ if (do_utf8) {
+ utf8_p = (U8 *) p;
+ } else {
+ STRLEN len = 1;
+ utf8_p = bytes_to_utf8(p, &len);
+ }
+ if (swash_fetch(sw, utf8_p, 1))
match = TRUE;
else if (flags & ANYOF_FOLD) {
if (!match && lenp && av) {
@@ -5780,8 +5787,7 @@ S_reginclass(pTHX_ const regexp *prog, register const regnode *n, register const
SV* const sv = *av_fetch(av, i, FALSE);
STRLEN len;
const char * const s = SvPV_const(sv, len);
-
- if (len <= plen && memEQ(s, (char*)p, len)) {
+ if (len <= plen && memEQ(s, (char*)utf8_p, len)) {
*lenp = len;
match = TRUE;
break;
@@ -5790,10 +5796,10 @@ S_reginclass(pTHX_ const regexp *prog, register const regnode *n, register const
}
if (!match) {
U8 tmpbuf[UTF8_MAXBYTES_CASE+1];
- STRLEN tmplen;
- to_utf8_fold(p, tmpbuf, &tmplen);
- if (swash_fetch(sw, tmpbuf, do_utf8))
+ STRLEN tmplen;
+ to_utf8_fold(utf8_p, tmpbuf, &tmplen);
+ if (swash_fetch(sw, tmpbuf, 1))
match = TRUE;
}
}