This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
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.