summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-10-27 16:02:44 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-10-28 16:15:09 -0700
commit2be08ad105a2a12613bb690aae26e2a9d3b225f2 (patch)
tree5c31ac0d954d982518e19ae7231f613d34cd7bf8 /gv.c
parent722fa0e9973574787e686d761e198d8854b28688 (diff)
downloadperl-2be08ad105a2a12613bb690aae26e2a9d3b225f2.tar.gz
gv:gv_try_downgrade: Leave PL_last_in_gv alone
gv_try_downgrade exists to remove globs and subs that were (possibly temporarily) vivified by bareword lookup. It is called whenever a gvop is freed and its gv looks like a candidate for downgrading. That means it applies, not only to potential sub calls, but also to *foo and *bar. gv_try_downgrade may delete a glob from the stash alto- gether if it is empty. So eval "*foo if 0" may delete the *foo glob. PL_last_in_gv is the internal variable underlying ${^LAST_FH}. If gv_try_downgrade deletes the last-read handle, then ${^LAST_FH} will become undefined, whereas eval "*foo if 0" is not supposed to do anything: $ ./miniperl -le 'readline *{"foo"}; warn ${^LAST_FH}; eval "*foo if 0"; warn ${^LAST_FH}' GLOB(0x7f8f5a0052a0) at -e line 1. Warning: something's wrong at -e line 1.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 93e6ccc95b..c7453156ce 100644
--- a/gv.c
+++ b/gv.c
@@ -3320,7 +3320,8 @@ Perl_gv_try_downgrade(pTHX_ GV *gv)
!GvSV(gv) && !GvAV(gv) && !GvHV(gv) && !GvIOp(gv) && !GvFORM(gv) &&
GvEGVx(gv) == gv && (stash = GvSTASH(gv))))
return;
- if (gv == PL_statgv || gv == PL_stderrgv) return;
+ if (gv == PL_statgv || gv == PL_last_in_gv || gv == PL_stderrgv)
+ return;
if (SvMAGICAL(gv)) {
MAGIC *mg;
/* only backref magic is allowed */