diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-01-13 15:50:51 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-01-13 21:24:54 -0800 |
commit | 97c226b87fecccdf4a4af5defd1836198a9666e5 (patch) | |
tree | f603e15adbff722a3289a39680687dfb3fd7636d /sv.c | |
parent | de61bf2ac7b4130886e0d3b93c1f0e22b7dfaec3 (diff) | |
download | perl-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.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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; } /* |