develooper Front page | perl.perl5.changes | Postings from September 2021

[Perl/perl5] c1d304: Fix a leak when copying a STATIC COW SV to astrin...

From:
Nicholas Clark via perl5-changes
Date:
September 11, 2021 12:04
Subject:
[Perl/perl5] c1d304: Fix a leak when copying a STATIC COW SV to astrin...
Message ID:
Perl/perl5/push/refs/heads/blead/e3dd96-c1d304@github.com
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: c1d304d234269da7c796c3a2df9f816ab377d4ba
      https://github.com/Perl/perl5/commit/c1d304d234269da7c796c3a2df9f816ab377d4ba
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-11 (Sat, 11 Sep 2021)

  Changed paths:
    M sv.c

  Log Message:
  -----------
  Fix a leak when copying a STATIC COW SV to a stringified SV

This is minor a a regression introduced by commit 914bb57489325d34:
    Define a third kind of COW state; STATIC

    ...

    sv_setsv_flags() and sv_setsv_cow() will preserve this state

There was a small omission in the copy code - it didn't handle the case where
the destination SV owned a string buffer already. This is actually
relatively rare - triggering it requires a scalar in code path that is
assigned both strings and booleans. Minimal test case is:

    my $got = 1;
    $got .= "";
    $got = ref "";

cut down from &is in t/comp/parser.t





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About