This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Data::Dumper (XS): use mortals to prevent leaks if magic throws
authorTony Cook <tony@develop-help.com>
Wed, 12 Aug 2020 06:20:16 +0000 (16:20 +1000)
committerKarl Williamson <khw@cpan.org>
Mon, 17 Aug 2020 02:17:01 +0000 (20:17 -0600)
commit815b4be4ab7ae210f796fc9d29754e55fc0d1f0e
treec17bacf0b643e3aef7dec319b795d21da879c92c
parentb98a3a6d08f681353d0b357fd1cce437c93656e7
Data::Dumper (XS): use mortals to prevent leaks if magic throws

For example:

  use Tie::Scalar;
  use Data::Dumper;
  sub T::TIESCALAR { bless {}, shift}
  sub T::FETCH { die }
  my $x;
  tie $x, "T" or die;
  while(1) {
      eval { () = Dumper( [ \$x ] ) };
  }

would leak various work SVs.

I start a new scope (ENTER/LEAVE) for most recursive DD_dump() calls
so that the work SVs don't accumulate on the temps stack, for example
if we're dumping a large array we'd end up with several SVs on the
temp stack for each member of the array.

The exceptions are where I don't expect a large number of unreleased
temps to accumulate, as with scalar or glob refs.
dist/Data-Dumper/Dumper.xs