HV backrefs: another simplification
authorDavid Mitchell <davem@iabyn.com>
Tue, 3 May 2011 16:16:29 +0000 (17:16 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 19 May 2011 13:49:43 +0000 (14:49 +0100)
Now that HV backrefs are only stored in HvAUX, don't go looking for them
in magic too in sv_clear()

sv.c

diff --git a/sv.c b/sv.c
index 534638c..8a66317 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -6054,9 +6054,12 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
        if (type >= SVt_PVMG) {
            /* Free back-references before magic, in case the magic calls
             * Perl code that has weak references to sv. */
-           if (type == SVt_PVHV)
+           if (type == SVt_PVHV) {
                Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv));
-           if (type == SVt_PVMG && SvPAD_OUR(sv)) {
+               if (SvMAGIC(sv))
+                   mg_free(sv);
+           }
+           else if (type == SVt_PVMG && SvPAD_OUR(sv)) {
                SvREFCNT_dec(SvOURSTASH(sv));
            } else if (SvMAGIC(sv)) {
                /* Free back-references before other types of magic. */