summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-05-12 18:43:13 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-05-21 21:41:08 -0700
commit0e80230dd03d4a00cfc60a9dfec380921ba15d8e (patch)
tree02a875f32b7fd4da2720e0ea4e9e376c8bf8ede9 /pp.c
parent1647a8f2ff38f2080e08a6e87b979fea169be893 (diff)
downloadperl-0e80230dd03d4a00cfc60a9dfec380921ba15d8e.tar.gz
Don’t crash with &CORE::foo after undefining *_
When a sub is called with & and no parentheses, no @_ is set up. This means the sub call sees the existing @_. It also means that, if *_ has been undefined, there is no @_. pp_coreargs was not accounting for this, and was doing AvARRAY(GvAV(PL_defgv)) without checking that GvAV(PL_defgv) was non- null. It crashed as a result.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index ba3ac1f0bf..ee82cd2c3a 100644
--- a/pp.c
+++ b/pp.c
@@ -5881,8 +5881,8 @@ PP(pp_coreargs)
int opnum = SvIOK(cSVOP_sv) ? (int)SvUV(cSVOP_sv) : 0;
int defgv = PL_opargs[opnum] & OA_DEFGV, whicharg = 0;
AV * const at_ = GvAV(PL_defgv);
- SV **svp = AvARRAY(at_);
- I32 minargs = 0, maxargs = 0, numargs = AvFILLp(at_)+1;
+ SV **svp = at_ ? AvARRAY(at_) : NULL;
+ I32 minargs = 0, maxargs = 0, numargs = at_ ? AvFILLp(at_)+1 : 0;
I32 oa = opnum ? PL_opargs[opnum] >> OASHIFT : 0;
bool seen_question = 0;
const char *err = NULL;