This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Properly dereference a ptr
authorKarl Williamson <khw@cpan.org>
Sat, 27 Sep 2014 23:13:42 +0000 (17:13 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 29 Sep 2014 17:07:40 +0000 (11:07 -0600)
UTF8_IS_INVARIANT takes a byte as its argument, not a ptr.  This bug was
introduced by 62a59291 in 5.21.4.  It doesn't probably cause bugs
because the ptr is always too big to be an invariant, but it slows
things down somewhat by not taking a shortcut it could.

It turns out that there is a discrepency between the APIs of the
UTF8-foo macros.  Some take a byte, and some a string ptr.

regcomp.c

index 27061b0..049d6e7 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13667,7 +13667,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
         }
         else {
             /* Is a backslash; get the code point of the char after it */
-           if (UTF && ! UTF8_IS_INVARIANT(RExC_parse)) {
+           if (UTF && ! UTF8_IS_INVARIANT(UCHARAT(RExC_parse))) {
                value = utf8n_to_uvchr((U8*)RExC_parse,
                                   RExC_end - RExC_parse,
                                   &numlen, UTF8_ALLOW_DEFAULT);