This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_return(): handle dounwind() freeing args
Currently only POPSUB (and other sub-like contexts, such as POPEVAL) do a
LEAVE_SCOPE() as well as restoring things from the context struct. This
means that if pp_return() does a dounwind() to pop back to the next
SUB/EVAL/FORMAT context, LEAVE_SCOPE() won't get called, and any return
values aren't prematurely freed, e.g. in the following
sub f {
for (...) {
my $x = 1;
return $x;
}
}
POPLOOP() won't call LEAVE_SCOPE(), so $x doesn't get freed.
The next commit is about to change that: POPLOOP() will indeed call
LEAVE_SCOPE(), (and later commits may make other POPFOO() types do that
too). So in preparation, this commit makes pp_return() preserve any return
args before calling dounwind().