diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-23 20:26:51 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-24 01:45:30 -0800 |
commit | e37d6bdb385bdcf32a72bdde366106ee4c503bfe (patch) | |
tree | e822a49d3102560178721d892a61d7d25a4b0b03 /t | |
parent | 9d6d5a7950f47e97191ed3cc7a45cd5b06163193 (diff) | |
download | perl-e37d6bdb385bdcf32a72bdde366106ee4c503bfe.tar.gz |
sysread should not ignore magic on its buffer
sysread uses SvPV_force, which has a bug in it. Even if the SV_GMAGIC
flag is passed to sv_pvn_force_flags (which SvPV_force does), it
ignores magic in any typeglob argument.
Diffstat (limited to 't')
-rw-r--r-- | t/op/gmagic.t | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/op/gmagic.t b/t/op/gmagic.t index daebae4cb8..c50205267c 100644 --- a/t/op/gmagic.t +++ b/t/op/gmagic.t @@ -61,6 +61,30 @@ $c = bless [], o::; chomp $c; expected_tie_calls(tied $c, 1, 2, 'chomping a ref'); +{ + my $outfile = tempfile(); + open my $h, ">$outfile" or die "$0 cannot close $outfile: $!"; + print $h "bar\n"; + close $h or die "$0 cannot close $outfile: $!"; + + $c = *foo; # 1 write + open $h, $outfile; + sysread $h, $c, 3, 7; # 1 read; 1 write + is $c, "*main::bar", 'what sysread wrote'; # 1 read + expected_tie_calls(tied $c, 2, 2, 'calling sysread with tied buf'); + close $h or die "$0 cannot close $outfile: $!"; + + # Do this again, with a utf8 handle + $c = *finish; # 1 write + open $h, "<:utf8", $outfile; + sysread $h, $c, 3, 7; # 1 read; 1 write + is $c, "*main::bar", 'what sysread wrote'; # 1 read + expected_tie_calls(tied $c, 2, 2, 'calling sysread with tied buf'); + close $h or die "$0 cannot close $outfile: $!"; + + unlink_all $outfile; +} + # autovivication of aelem, helem, of rv2sv combined with get-magic { my $true = 1; |