This code in sv_setsv, introduced in
ece467f9b3, can’t possi-
bly be right:
if ( SvVOK(dstr) )
{
/* need to nuke the magic */
mg_free(dstr);
}
And here is a test to prove it:
sub TIESCALAR { bless[]}
sub STORE {}
tie $@, "";
$@ = v0;
warn tied $@; # main=ARRAY(0xc0ffee)
$@ = 3;
warn tied $@; # something’s wrong
It blows away tiedness.
You could do that to any variable.
Let’s see:
$! = v0;
$! = 3;
open foo, 'oentuhaeontu' or die $!; # 3 at - line 3.
Youch!
Let’s just free vstring magic, shall we?
if ( SvVOK(dstr) )
{
/* need to nuke the magic */
- mg_free(dstr);
+ sv_unmagic(dstr, PERL_MAGIC_vstring);
}
/* There's a lot of redundancy below but we're going for speed here */
use Config;
-plan( tests => 54 );
+plan( tests => 55 );
eval 'use v5.5.640';
is( $@, '', "use v5.5.640; $@");
%h = (65.66.67 => 42);
ok( exists $h{chr(65).chr(66).chr(67)}, "v-stringness is engaged for X.Y.Z" );
+{
+ local $|;
+ $| = v0;
+ $| = 1;
+ --$|; --$|;
+ is $|, 1, 'clobbering vstrings does not clobber all magic';
+}
+
# The following tests whether v-strings are correctly
# interpreted by the tokeniser when it's in a XTERMORDORDOR