From: SADAHIRO Tomoyuki Date: Tue, 6 Dec 2005 00:35:52 +0000 (+0900) Subject: Re: [perl #37836] Simple Regex causes SEGV when run on specific data X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=19f6729910f1cd22aa33cc8443fa168b7813bd95;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #37836] Simple Regex causes SEGV when run on specific data Message-Id: <20051206003221.5AD9.BQW10602@nifty.com> p4raw-id: //depot/perl@26258 --- diff --git a/regexec.c b/regexec.c index b0ba851..13cc68b 100644 --- a/regexec.c +++ b/regexec.c @@ -4710,9 +4710,13 @@ S_reginclass(pTHX_ register const regnode *n, register const U8* p, STRLEN* lenp STRLEN len = 0; STRLEN plen; - if (do_utf8 && !UTF8_IS_INVARIANT(c)) - c = utf8n_to_uvchr(p, UTF8_MAXBYTES, &len, - ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY); + if (do_utf8 && !UTF8_IS_INVARIANT(c)) { + c = utf8n_to_uvchr(p, UTF8_MAXBYTES, &len, + ckWARN(WARN_UTF8) ? UTF8_CHECK_ONLY : + UTF8_ALLOW_ANYUV|UTF8_CHECK_ONLY); + if (len == (STRLEN)-1) + Perl_croak(aTHX_ "Malformed UTF-8 character (fatal)"); + } plen = lenp ? *lenp : UNISKIP(NATIVE_TO_UNI(c)); if (do_utf8 || (flags & ANYOF_UNICODE)) {