diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-07-29 10:14:26 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-07-29 10:14:26 +0000 |
commit | 13207a7148ab5967a6d91a9acb60e5e292572de2 (patch) | |
tree | 34119d249de911fa88ccd60aa62f4167cb71f9b1 /gv.c | |
parent | e2d37721ce786c2356aa09668585a35df28412e9 (diff) | |
download | perl-13207a7148ab5967a6d91a9acb60e5e292572de2.tar.gz |
Most importantly, don't try HvNAME(gp->gp_hv)
unless PL_stashcache exists, otherwise we get
an invalid read (detected by valgrind, and crashes
ext/threads/t/basic.t in Windows).
Also add a few if:s for the refcnt decrements,
no need to call Perl_sv_free() if there's nothing to free.
p4raw-id: //depot/perl@20292
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -1252,14 +1252,18 @@ Perl_gp_free(pTHX_ GV *gv) return; } - SvREFCNT_dec(gp->gp_sv); - SvREFCNT_dec(gp->gp_av); - if(gp->gp_hv && HvNAME(gp->gp_hv) && PL_stashcache) - hv_delete(PL_stashcache, HvNAME(gp->gp_hv), strlen(HvNAME(gp->gp_hv)), G_DISCARD); - SvREFCNT_dec(gp->gp_hv); - SvREFCNT_dec(gp->gp_io); - SvREFCNT_dec(gp->gp_cv); - SvREFCNT_dec(gp->gp_form); + if (gp->gp_sv) SvREFCNT_dec(gp->gp_sv); + if (gp->gp_sv) SvREFCNT_dec(gp->gp_av); + if (gp->gp_hv) { + if (PL_stashcache && HvNAME(gp->gp_hv)) + hv_delete(PL_stashcache, + HvNAME(gp->gp_hv), strlen(HvNAME(gp->gp_hv)), + G_DISCARD); + SvREFCNT_dec(gp->gp_hv); + } + if (gp->gp_io) SvREFCNT_dec(gp->gp_io); + if (gp->gp_cv) SvREFCNT_dec(gp->gp_cv); + if (gp->gp_form) SvREFCNT_dec(gp->gp_form); Safefree(gp); GvGP(gv) = 0; |