This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_newLISTOP() allocate OP_PUSHMARK safely
authorDavid Mitchell <davem@iabyn.com>
Thu, 11 Apr 2019 16:19:31 +0000 (17:19 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 12 Apr 2019 14:58:04 +0000 (15:58 +0100)
commita64296af735e8e25c8a1b58cd36a97211c371ac4
tree6426295c643112830d9faa1c49d1551e3324fcbb
parent8cc54175018f1cabb5c0354371c9e2ee24f8ee5a
Perl_newLISTOP() allocate OP_PUSHMARK safely

This commit is a prelude to allowing op_free() to make use the parent
pointer at the end of an op_sibling chain to walk a sub-tree to be freed.

newLISTOP() converts 0..2 ops into a list, adding a new parent list op
and possibly a pushmark op. However, under Safe.pm, and specifically in
dist/Safe/t/safeops.t, allocating a pushmark can croak. If the optree
under construct at this point isn't consistent (specifically the parent
pointer not yet set), then this can crash op_free() while trying to walk
the new list to free it.

The fix is to allocate the OP_PUSHMARK if needed *before* messing with
the structure of the list sub-tree.
op.c