This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re-introduce the changes from change 68 (runops becomes a
[perl5.git] / sv.c
diff --git a/sv.c b/sv.c
index cd55f81..1c58c46 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4043,9 +4043,10 @@ I32 n;
 }
 
 SV*
-sv_bless(sv,stash)
+sv_bless3(sv,stash,zaptilde)
 SV* sv;
 HV* stash;
+bool zaptilde;
 {
     dTHR;
     SV *ref;
@@ -4058,6 +4059,8 @@ HV* stash;
        if (SvOBJECT(ref)) {
            if (SvTYPE(ref) != SVt_PVIO)
                --sv_objcount;
+           if (zaptilde && SvRMAGICAL(ref))
+               sv_unmagic(ref, '~');   /* stop cross-class pointer forgery */
            SvREFCNT_dec(SvSTASH(ref));
        }
     }
@@ -4077,6 +4080,14 @@ HV* stash;
     return sv;
 }
 
+SV*
+sv_bless(sv,stash)
+SV* sv;
+HV* stash;
+{
+    return sv_bless3(sv, stash, FALSE);
+}
+
 static void
 sv_unglob(sv)
 SV* sv;