This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hv.c: hv_undef: Don’t set mro fields to null before freeing
authorFather Chrysostomos <sprout@cpan.org>
Sat, 8 Dec 2012 17:58:31 +0000 (09:58 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 10 Dec 2012 02:47:18 +0000 (18:47 -0800)
There is no point in modifying a struct just before freeing it.

This was my mistake, in commit 47f1cf7702, when I moved the code from
S_hfreeentries to hv_undef.

hv.c

diff --git a/hv.c b/hv.c
index 23130cc..e9e3b27 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1753,16 +1753,14 @@ Perl_hv_undef_flags(pTHX_ HV *hv, U32 flags)
       }
       if((meta = aux->xhv_mro_meta)) {
        if (meta->mro_linear_all) {
-           SvREFCNT_dec(MUTABLE_SV(meta->mro_linear_all));
-           meta->mro_linear_all = NULL;
-           /* This is just acting as a shortcut pointer.  */
-           meta->mro_linear_current = NULL;
-       } else if (meta->mro_linear_current) {
+           SvREFCNT_dec_NN(meta->mro_linear_all);
+           /* mro_linear_current is just acting as a shortcut pointer,
+              hence the else.  */
+       }
+       else
            /* Only the current MRO is stored, so this owns the data.
             */
            SvREFCNT_dec(meta->mro_linear_current);
-           meta->mro_linear_current = NULL;
-       }
        SvREFCNT_dec(meta->mro_nextmethod);
        SvREFCNT_dec(meta->isa);
        Safefree(meta);