S_opdump_indent(): avoid shift overflow
authorDavid Mitchell <davem@iabyn.com>
Thu, 17 Aug 2017 07:25:50 +0000 (08:25 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 17 Aug 2017 07:27:36 +0000 (08:27 +0100)
RT #131912

the (1 << i) is harmless for large i, but triggers an 'undefined-behavior'
errror in clang.

So work around it.

dump.c

diff --git a/dump.c b/dump.c
index 1fa2422..1628ca3 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -578,7 +578,10 @@ S_opdump_indent(pTHX_ const OP *o, I32 level, UV bar, PerlIO *file,
         /* output preceding blank line */
         PerlIO_puts(file, "     ");
         for (i = level-1; i >= 0; i--)
-            PerlIO_puts(file,  i == 0 || (bar & (1 << i)) ?  "|   " : "    ");
+            PerlIO_puts(file,  (   i == 0
+                                || (i < UVSIZE*8 && (bar & ((UV)1 << i)))
+                               )
+                                    ?  "|   " : "    ");
         PerlIO_puts(file, "\n");
 
         /* output sequence number */