diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-07-26 01:26:54 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-08-25 12:25:23 -0700 |
commit | 35995e5cabcbf47f272bbb0fb290908515c1d776 (patch) | |
tree | 4ac6fe162e158e5b465168b2e628ab2d5cdefd29 /t/op/pos.t | |
parent | 232af1f839acc29d9ac336d13ff67802d236c38b (diff) | |
download | perl-35995e5cabcbf47f272bbb0fb290908515c1d776.tar.gz |
Fix assert fail when fetching pos clobbers ref with undef
pos($x) returns a special magical scalar that sets the match position
on $x. Calling pos($x) twice will provide two such scalars. If we
set one of them to a reference, set the other to undef, and then read
the first, all hail breaks loose, because of the use of SvOK_off.
SvOK_off is not sufficient if arbitrary values can be assigned by Perl
code. Globs, refs and regexps (among others) need special handling,
which sv_setsv knows how to do.
Diffstat (limited to 't/op/pos.t')
-rw-r--r-- | t/op/pos.t | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/t/op/pos.t b/t/op/pos.t index e9c863b5e4..04b527246d 100644 --- a/t/op/pos.t +++ b/t/op/pos.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 28; +plan tests => 29; $x='banana'; $x=~/.a/g; @@ -122,3 +122,12 @@ $x =~ /.(?{ })/; is $w, undef, 'and no malformed utf8 warning'; } + +for my $one(pos $x) { + for my $two(pos $x) { + $one = \1; + $two = undef; + is $one, undef, + 'no assertion failure when getting pos clobbers ref with undef'; + } +} |