summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-24 23:35:52 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-24 23:35:52 -0800
commit0df2568b7d017f31f412f393b443d798ed61602d (patch)
tree2bacfabdb7525b985583dfb1deff9344cf695799 /pp_sys.c
parent204263bc1eb63f1dfd6180c05dca8cec2c319504 (diff)
downloadperl-0df2568b7d017f31f412f393b443d798ed61602d.tar.gz
select() can return undef when defoutgv is set
If PL_defoutgv has been deleted from its stash, select() returns it as a ref, but if the stash has been freed (even though the gv still exists), it returns undef. That makes no sense. This is one of those nice cases where simplifying the code fixes a bug.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 661e0fca0e..a5fcb00e4d 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1224,24 +1224,20 @@ PP(pp_select)
HV *hv;
GV * const newdefout = (PL_op->op_private > 0) ? (MUTABLE_GV(POPs)) : NULL;
GV * egv = GvEGVx(PL_defoutgv);
+ GV * const *gvp;
if (!egv)
egv = PL_defoutgv;
hv = isGV_with_GP(egv) ? GvSTASH(egv) : NULL;
- if (! hv)
- XPUSHs(&PL_sv_undef);
- else {
- GV * const * const gvp =
- HvENAME(hv)
+ gvp = hv && HvENAME(hv)
? (GV**)hv_fetch(hv, GvNAME(egv), HEK_UTF8(GvNAME_HEK(egv)) ? -GvNAMELEN(egv) : GvNAMELEN(egv), FALSE)
: NULL;
- if (gvp && *gvp == egv) {
+ if (gvp && *gvp == egv) {
gv_efullname4(TARG, PL_defoutgv, NULL, TRUE);
XPUSHTARG;
- }
- else {
+ }
+ else {
mXPUSHs(newRV(MUTABLE_SV(egv)));
- }
}
if (newdefout) {