summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-07-29 10:14:26 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-07-29 10:14:26 +0000
commit13207a7148ab5967a6d91a9acb60e5e292572de2 (patch)
tree34119d249de911fa88ccd60aa62f4167cb71f9b1 /gv.c
parente2d37721ce786c2356aa09668585a35df28412e9 (diff)
downloadperl-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.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gv.c b/gv.c
index a5dbb95ddc..8a9b803b1c 100644
--- a/gv.c
+++ b/gv.c
@@ -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;