Don’t clobber all magic when clobbering vstring
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?