From: David Mitchell Date: Tue, 10 May 2011 12:52:48 +0000 (+0100) Subject: hv_free_ent: free SV as last action X-Git-Tag: v5.15.0~526 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/272e8453abcb0fceb34b1464670386e03a1f55bb hv_free_ent: free SV as last action Move the freeing of the SV from near the beginning to the end of hv_free_ent(); i.e. free the HE before the SV. Ideally, this should cause no change in behaviour, but will make using an iterative HV freeing scheme easier. --- diff --git a/hv.c b/hv.c index 20c3531..e78f84f 100644 --- a/hv.c +++ b/hv.c @@ -1470,7 +1470,6 @@ Perl_hv_free_ent(pTHX_ HV *hv, register HE *entry) val = HeVAL(entry); if (val && isGV(val) && isGV_with_GP(val) && GvCVu(val) && HvENAME(hv)) mro_method_changed_in(hv); /* deletion of method from stash */ - SvREFCNT_dec(val); if (HeKLEN(entry) == HEf_SVKEY) { SvREFCNT_dec(HeKEY_sv(entry)); Safefree(HeKEY_hek(entry)); @@ -1480,6 +1479,7 @@ Perl_hv_free_ent(pTHX_ HV *hv, register HE *entry) else Safefree(HeKEY_hek(entry)); del_HE(entry); + SvREFCNT_dec(val); }