Another needle in the voodoo doll.
Artur Bergman [Thu, 17 Apr 2003 20:02:33 +0000 (20:02 +0000)]
Now I think it should work with the shared
strings.

p4raw-id: //depot/perl@19262

sv.c

diff --git a/sv.c b/sv.c
index 6a4dcf1..5a51269 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -9864,14 +9864,20 @@ Perl_rvpv_dup(pTHX_ SV *dstr, SV *sstr, CLONE_PARAMS* param)
            /* Special case - not normally malloced for some reason */
            if (SvREADONLY(sstr) && SvFAKE(sstr)) {
                /* A "shared" PV - clone it as unshared string */
-                if(!SvPADTMP(sstr)) {
+                if(SvPADTMP(sstr)) {
                     /* However, some of them live in the pad
                        and they should not have these flags
                        turned off */
-                   SvFAKE_off(dstr);
-                   SvREADONLY_off(dstr);
+
+                    SvPVX(dstr) = sharepvn(SvPVX(sstr), SvCUR(sstr),
+                                           SvUVX(sstr));
+                    SvUVX(dstr) = SvUVX(sstr);
+                } else {
+
+                    SvPVX(dstr) = SAVEPVN(SvPVX(sstr), SvCUR(sstr));
+                    SvFAKE_off(dstr);
+                    SvREADONLY_off(dstr);
                 }
-               SvPVX(dstr) = SAVEPVN(SvPVX(sstr), SvCUR(sstr));
            }
            else {
                /* Some other special case - random pointer */