This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid a SIGBUS caused by passing a U32 pointer to utf8_to_uvchr(),
authorNicholas Clark <nick@ccl4.org>
Thu, 26 Apr 2007 20:43:13 +0000 (20:43 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 26 Apr 2007 20:43:13 +0000 (20:43 +0000)
which expects a STRLEN pointer.
Avoid some signed/unsigned casting warnings by adding casts.

p4raw-id: //depot/perl@31093

regcomp.c
regexec.c

index 40b2ac1..80aa335 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -6576,7 +6576,7 @@ tryagain:
     case 0xC3:
     case 0xCE:
         if (FOLD && is_TRICKYFOLD(RExC_parse,UTF)) {
-            U32 len = UTF ? 0 : 1;
+            STRLEN len = UTF ? 0 : 1;
             U32 cp = UTF ? utf8_to_uvchr((U8*)RExC_parse, &len) : (U32)((U8*)RExC_parse)[0];
             *flagp |= HASWIDTH; /* could be SIMPLE too, but needs a handler in regexec.regrepeat */
             RExC_parse+=len;
index 374d480..79fab43 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -5022,8 +5022,9 @@ NULL
                     U8 tmpbuf2[UTF8_MAXBYTES_CASE+1];
                     STRLEN tmplen2;
                     to_uni_fold(n, tmpbuf1, &tmplen1);
-                    to_utf8_fold(locinput, tmpbuf2, &tmplen2);    
-                    if (tmplen1!=tmplen2 || !strnEQ(tmpbuf1,tmpbuf2,tmplen1))
+                    to_utf8_fold((U8*)locinput, tmpbuf2, &tmplen2);    
+                    if (tmplen1!=tmplen2
+                       || !strnEQ((char *)tmpbuf1,(char *)tmpbuf2,tmplen1))
                         sayNO;
                     else 
                         locinput += UTF8SKIP(locinput);