Purify: Array bounds write: pre-extend the strxfrm
authorJarkko Hietaniemi <jhi@iki.fi>
Sat, 23 Mar 2002 01:00:31 +0000 (01:00 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 23 Mar 2002 01:00:31 +0000 (01:00 +0000)
buffer by a factor of four (suggested maximum by HP-UX;
Solaris suggests using 1 + strxfrm(NULL, s, 0) but I don't
know how portable that is; locale.c uses yet another trick
(not a particularly good trick, I might add))

p4raw-id: //depot/perl@15435

ext/POSIX/POSIX.xs

index 238c528..2d1abf3 100644 (file)
@@ -1568,7 +1568,7 @@ strxfrm(src)
           STRLEN dstlen;
           char *p = SvPV(src,srclen);
           srclen++;
-          ST(0) = sv_2mortal(NEWSV(800,srclen));
+          ST(0) = sv_2mortal(NEWSV(800,srclen*4+1));
           dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
           if (dstlen > srclen) {
               dstlen++;