From ecf0432f1e8289d3b387151b8bf1968133dda7f2 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 26 Sep 2010 14:28:31 -0700 Subject: $ perl5.6.2 -MData::Dumper -le' Data::Dumper->Dumpxs([*{*STDERR{IO}}])' Bus error Same in 5.11.4. This is related to bug 71254. It turns out that globs *can* stringify emptily (see bug 65582). This patch makes DD more resilient. --- dist/Data-Dumper/Dumper.xs | 2 +- dist/Data-Dumper/t/bugs.t | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'dist') diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs index 52a57f8c8c..78459624ae 100644 --- a/dist/Data-Dumper/Dumper.xs +++ b/dist/Data-Dumper/Dumper.xs @@ -909,7 +909,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv, } else if (realtype == SVt_PVGV) {/* GLOBs can end up with scribbly names */ c = SvPV(val, i); - ++c; --i; /* just get the name */ + if(i) ++c, --i; /* just get the name */ if (i >= 6 && strncmp(c, "main::", 6) == 0) { c += 4; i -= 4; diff --git a/dist/Data-Dumper/t/bugs.t b/dist/Data-Dumper/t/bugs.t index cf2803f900..3c5d141298 100644 --- a/dist/Data-Dumper/t/bugs.t +++ b/dist/Data-Dumper/t/bugs.t @@ -12,7 +12,7 @@ BEGIN { } use strict; -use Test::More tests => 5; +use Test::More tests => 6; use Data::Dumper; { @@ -80,4 +80,9 @@ sub doh doh('fixed'); ok(1, "[perl #56766]"); # Still no core dump? We are fine. +# [perl #72332] Segfault on empty-string glob +Data::Dumper->Dump([*{*STDERR{IO}}]); +ok("ok", #ok + "empty-string glob [perl #72332]"); + # EOF -- cgit v1.2.1