summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-13 15:50:51 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-13 21:24:54 -0800
commit97c226b87fecccdf4a4af5defd1836198a9666e5 (patch)
treef603e15adbff722a3289a39680687dfb3fd7636d /sv.c
parentde61bf2ac7b4130886e0d3b93c1f0e22b7dfaec3 (diff)
downloadperl-97c226b87fecccdf4a4af5defd1836198a9666e5.tar.gz
Set PL_statgv to null when freed or coerced
If PL_statgv is not set to null when freed, that same SV could be reused for another GV, in which case -T _ will then use another handle unrelated to the previous stat. Similarly, if PL_statgv points to a fake glob that gets coerced into a non-glob before it is freed, it will not follow the code path in sv_free that sets PL_statgv to null. Furthermore, if it becomes a GV again, it could be a completely different filehandle, unrelated to the previous stat.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index 1f9f78774a..b04649b03f 100644
--- a/sv.c
+++ b/sv.c
@@ -6136,6 +6136,8 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
/* See also S_sv_unglob, which does the same thing. */
if ((const GV *)sv == PL_last_in_gv)
PL_last_in_gv = NULL;
+ else if ((const GV *)sv == PL_statgv)
+ PL_statgv = NULL;
case SVt_PVMG:
case SVt_PVNV:
case SVt_PVIV:
@@ -9542,6 +9544,8 @@ S_sv_unglob(pTHX_ SV *const sv, U32 flags)
if ((const GV *)sv == PL_last_in_gv)
PL_last_in_gv = NULL;
+ else if ((const GV *)sv == PL_statgv)
+ PL_statgv = NULL;
}
/*