summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-23 14:28:33 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-23 14:45:55 -0800
commit190e89f069481aa08def70f73170ade1d6d1fca9 (patch)
tree49bce15d1828829087717ef3ec4a3e056de5147f /sv.c
parent0b7a369cae77008a12eaaee38c4a63fd344fca22 (diff)
downloadperl-190e89f069481aa08def70f73170ade1d6d1fca9.tar.gz
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?
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index 019e8dd11c..39ddbff86e 100644
--- a/sv.c
+++ b/sv.c
@@ -3949,7 +3949,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV* sstr, const I32 flags)
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 */