This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix sprintf multiconcat on 32bit big-endian systems with use64bitint
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Wed, 8 Nov 2017 20:25:56 +0000 (20:25 +0000)
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Sun, 12 Nov 2017 20:46:54 +0000 (20:46 +0000)
The sprintf offset calculation was assigning to the 'uv' field of the
aux union, while the code was reading from the 'size' field, which leads
to all zeroes when sizeof(uv) > sizeof(size_t) on a big-endian system.

op.c

diff --git a/op.c b/op.c
index 368f9b1..15fe1af 100644 (file)
--- a/op.c
+++ b/op.c
@@ -3095,14 +3095,14 @@ S_maybe_multiconcat(pTHX_ OP *o)
             if (*p == '%') {
                 p++;
                 if (*p != '%') {
-                    (lenp++)->uv = q - oldq;
+                    (lenp++)->size = q - oldq;
                     oldq = q;
                     continue;
                 }
             }
             *q++ = *p;
         }
-        lenp->uv = q - oldq;
+        lenp->size = q - oldq;
         assert((STRLEN)(q - const_str) == total_len);
 
         /* Attach all the args (i.e. the kids of the sprintf) to o (which