This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid leak/crash calling CORE::foo()
authorDavid Mitchell <davem@iabyn.com>
Tue, 9 Apr 2019 09:33:34 +0000 (10:33 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 12 Apr 2019 14:58:04 +0000 (15:58 +0100)
commitad9115fb3ef3c0d588afd07c1b794e99cef3e1ed
treed5f299ad474654a05d85e0311987d20977af15ab
parent78bb3b143c41ff368fdc4a87f7e9bf36b3023ca2
Avoid leak/crash calling CORE::foo()

The compile time code in Perl_ck_entersub_args_core() that converts a
subroutine call like mypos(1,2) into a direct call to the built-in
function, e.g. pos(1,2), doesn't handle too many args well.
The ops associated with the extra args are excised from the op tree,
but aren't freed, and their op_sigparent pointers aren't updated
correctly.

This is noticeable if op_free() is altered to walk the tree using
op_sigparent to walk back up to the parent.

This commit frees any extra args and emits the 'Too many arguments' error
immediately, rather than tripping over later.
op.c
t/op/coresubs.t