This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #131665) avoid a buffer overflow in a buffer we didn't need
[perl5.git] / dump.c
diff --git a/dump.c b/dump.c
index fa5f0ba..a2c0bbc 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 */
@@ -1836,7 +1839,12 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
                 PerlIO_printf(file, "\n");
             }
            Perl_dump_indent(aTHX_ level, file, "  CUR = %" IVdf "\n", (IV)SvCUR(sv));
-           if (!re)
+           if (re && type == SVt_PVLV)
+                /* LV-as-REGEXP usurps len field to store pointer to
+                 * regexp struct */
+               Perl_dump_indent(aTHX_ level, file, "  REGEXP = 0x%" UVxf "\n",
+                   PTR2UV(((XPV*)SvANY(sv))->xpv_len_u.xpvlenu_rx));
+            else
                Perl_dump_indent(aTHX_ level, file, "  LEN = %" IVdf "\n",
                                       (IV)SvLEN(sv));
 #ifdef PERL_COPY_ON_WRITE