restore_magic needs to undo COW
authorNicholas Clark <nick@ccl4.org>
Sat, 22 Nov 2003 21:21:22 +0000 (21:21 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 22 Nov 2003 21:21:22 +0000 (21:21 +0000)
(while magic was off, sv_setsv is likely to have seen this SV as a
good source for COW)
Should fix the smoke failures on lib/locale.t

p4raw-id: //depot/perl@21774

mg.c

diff --git a/mg.c b/mg.c
index 494a4e2..92aa03f 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2583,6 +2583,13 @@ restore_magic(pTHX_ void *p)
 
     if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv))
     {
+#ifdef PERL_COPY_ON_WRITE
+       /* While magic was saved (and off) sv_setsv may well have seen
+          this SV as a prime candidate for COW.  */
+       if (SvIsCOW(sv))
+           sv_force_normal(sv);
+#endif
+
        if (mgs->mgs_flags)
            SvFLAGS(sv) |= mgs->mgs_flags;
        else