Pseudo-fork dups arg array on argless calls
authorDavid Mitchell <davem@iabyn.com>
Mon, 28 Apr 2014 10:50:20 +0000 (11:50 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 28 Apr 2014 11:06:37 +0000 (12:06 +0100)
commit96258673547f51dc588c290d9c8ff3d9b2b93397
treece3e5c5a459be0330256e9d4a14c48597b28e611
parentff0f0afd310f2278d5aafe2eb57ebeb0fda278b2
Pseudo-fork dups arg array on argless calls

RT #121721.

A subroutine call like &foo; pushes a SUB context with the savearray field
unassigned, and with CxHASARGS() false. Most of the core knows not to use
this field without CxHASARGS() being true: except for Perl_cx_dup(),
which was still trying to dup it. This could lead to SEGVs on a fresh CX
stack, or possibly duping some other sub's @_ on a reused stack entry.

The fix is simple; don't dup this field unless CxHASARGS() is set.
Note that a similar test is already in place for the argarray field.
sv.c
t/op/fork.t