summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-06-12 21:13:14 +0100
committerCraig A. Berry <craigberry@mac.com>2010-08-23 19:14:43 -0500
commit81d65e2b731b0dc785456578fd92e34a27a1c670 (patch)
treebee9f3a9d5afb620633db33230ba80d5c8c0654b
parent697790afdcc31ef010b4361b36bfb23c8e798c25 (diff)
downloadperl-81d65e2b731b0dc785456578fd92e34a27a1c670.tar.gz
Fix edge case in pp_eof where the stack extent was not checked.
Analogous to pp_getc and pp_tell in ac3697cd90b00fae, pp_eof has a conditional POP from the stack, but an unconditional PUSH to the stack, but no check that the stack had space for the PUSH. This bug has been present since perl 5.000. (with slight tweak for maint to avoid tripping over the absence of 099be4f)
-rw-r--r--pp_sys.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/pp_sys.c b/pp_sys.c
index f9339b590f..18b0d78f9f 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2019,10 +2019,14 @@ PP(pp_eof)
if (MAXARG)
gv = PL_last_in_gv = MUTABLE_GV(POPs); /* eof(FH) */
- else if (PL_op->op_flags & OPf_SPECIAL)
- gv = PL_last_in_gv = GvEGV(PL_argvgv); /* eof() - ARGV magic */
- else
- gv = PL_last_in_gv; /* eof */
+ else {
+ EXTEND(SP, 1);
+
+ if (PL_op->op_flags & OPf_SPECIAL)
+ gv = PL_last_in_gv = GvEGV(PL_argvgv); /* eof() - ARGV magic */
+ else
+ gv = PL_last_in_gv; /* eof */
+ }
if (!gv)
RETPUSHNO;