utf8.c: Don't do ++ in macro parameter
authorKarl Williamson <public@khwilliamson.com>
Sat, 6 Apr 2013 18:53:07 +0000 (12:53 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 29 Aug 2013 15:56:05 +0000 (09:56 -0600)
The formal parameter gets evaluated multiple times on an EBCDIC
platform, thus incrementing more than the intended once.

utf8.c

diff --git a/utf8.c b/utf8.c
index 1570fc8..64da27d 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1335,9 +1335,10 @@ Perl_bytes_from_utf8(pTHX_ const U8 *s, STRLEN *len, bool *is_utf8)
     s = start; start = d;
     while (s < send) {
        U8 c = *s++;
-       if (!UTF8_IS_INVARIANT(c)) {
+       if (! UTF8_IS_INVARIANT(c)) {
            /* Then it is two-byte encoded */
-           c = TWO_BYTE_UTF8_TO_NATIVE(c, *s++);
+           c = TWO_BYTE_UTF8_TO_NATIVE(c, *s);
+            s++;
        }
        *d++ = c;
     }