From: Father Chrysostomos Date: Mon, 18 Jan 2010 20:57:01 +0000 (+0100) Subject: Fix for #71254: SEGV in Data::Dumper X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f730e6c11736bad913e605b064200a67117e898;p=p5sagit%2Fp5-mst-13.2.git Fix for #71254: SEGV in Data::Dumper This was caused by change 27323/f7877b281b4, which changes the way globs are stored in SVs. This patch teaches Perl_magic_setmglob (which resets the match position after an assignment) about globs. What was happening was that the globness was turned off (with the type still as PVGV), which essentially turned the variable into a strange empty string. Data::Dumper, seeing a PVGV, assumes the string form is at least 1 char (which should always be the case), and ends up reading past the end of the string if it is blank. --- diff --git a/mg.c b/mg.c index 1728752..b9a1464 100644 --- a/mg.c +++ b/mg.c @@ -2217,7 +2217,8 @@ Perl_magic_setmglob(pTHX_ SV *sv, MAGIC *mg) PERL_ARGS_ASSERT_MAGIC_SETMGLOB; PERL_UNUSED_CONTEXT; mg->mg_len = -1; - SvSCREAM_off(sv); + if (!isGV_with_GP(sv)) + SvSCREAM_off(sv); return 0; } diff --git a/t/op/gv.t b/t/op/gv.t index 72787c4..6f16ce2 100644 --- a/t/op/gv.t +++ b/t/op/gv.t @@ -12,7 +12,7 @@ BEGIN { use warnings; require './test.pl'; -plan( tests => 181 ); +plan( tests => 182 ); # type coersion on assignment $foo = 'foo'; @@ -581,6 +581,17 @@ foreach my $type (qw(integer number string)) { is($str, '', "RT #60954 anon glob stringification should be empty"); } +# [perl #71254] - Assigning a glob to a variable that has a current +# match position. (We are testing that Perl_magic_setmglob respects globs' +# special used of SvSCREAM.) +{ + $m = 2; $m=~s/./0/gems; $m= *STDERR; + is( + "$m", "*main::STDERR", + '[perl #71254] assignment of globs to vars with pos' + ); +} + __END__ Perl Rules