diff options
author | David Mitchell <davem@iabyn.com> | 2010-03-30 15:03:50 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-03-30 15:03:50 +0100 |
commit | 099be4f1d597471eb719c9a344b7c1b55e11ba24 (patch) | |
tree | 46ddeb749d35c52c3df9d34f54e7200aef8ddbcf /gv.h | |
parent | 447ee1343739cf8e34c4ff1ba9b30eae75c3f1ab (diff) | |
download | perl-099be4f1d597471eb719c9a344b7c1b55e11ba24.tar.gz |
PL_defoutgv isn't always a GV.
Nasty code like the following results in PL_defoutgv not pointing
to a valid GV:
my $x = *STDERR; select($x); $x = 1;
This causes all sorts of SEGVs when PL_defoutgv is subsequently accessed,
because most code assumes that it has a valid gv_gp pointer. It also
turns out that PL_defoutgv is under-tested; for example, temporarily
hacking pp_close to make an arg-less close() croak didn't cause any
minitest failures.
Add a new test file that does some basic testing of a bad PL_defoutgv,
and fix all the obvious badness in accessing it.
This also fixes #20727, which although ostensibly a tie bug, was due to
PL_defoutgv pointing to a tiedelem scalar, and fun like that described
above happening.
Diffstat (limited to 'gv.h')
-rw-r--r-- | gv.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -114,6 +114,7 @@ Return the SV from the GV. #define GvFILEGV(gv) (gv_fetchfile(GvFILE(gv))) #define GvEGV(gv) (GvGP(gv)->gp_egv) +#define GvEGVx(gv) (isGV_with_GP(gv) ? GvEGV(gv) : NULL) #define GvENAME(gv) GvNAME(GvEGV(gv) ? GvEGV(gv) : gv) #define GvESTASH(gv) GvSTASH(GvEGV(gv) ? GvEGV(gv) : gv) |