Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 25a36e71fc493a6139ad72fbee25617b129969f1
      
https://github.com/Perl/perl5/commit/25a36e71fc493a6139ad72fbee25617b129969f1
  Author: David Mitchell <[email protected]>
  Date:   2023-01-04 (Wed, 04 Jan 2023)

  Changed paths:
    M dist/Storable/Storable.pm
    M dist/Storable/Storable.xs

  Log Message:
  -----------
  Storable: add missing PUTBACK in store_code()

store_code() does a POPs, but not a PUTBACK, before returning, so
PL_stack_sp was one too high on return. For example in the following
code:

    use Storable qw(freeze);

    my $obj = [
            sub { 1; },
            sub { 2; },
            sub { 4; },
            sub { 4; },
         ];

    $Storable::Deparse = 1;

    while (1) {
        my $freezed = freeze $obj;
    }

On the first four calls to store_code() - to deparse each of the anon
subs - PL_stack_sp is one higher than the previous call.

On subsequent calls to freeze(), PL_stack_sp is reset to its original
value.

I don't know whether this bug has any visible effects; I spotted it during
my work to make the stack reference-counted; PL_stack_sp not being
decremented caused the SV at that location to be double-counted.


Reply via email to