This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Respect SvLEN==0 and SvOOK in sv.c:sv_sethek
authorFather Chrysostomos <sprout@cpan.org>
Wed, 7 Aug 2013 16:04:20 +0000 (09:04 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 10 Aug 2013 02:28:33 +0000 (19:28 -0700)
commitfff2dea573c6a4eadf4c2df969590ce0b48e1777
tree50f905372b02afef48befbd9574513115e98fc9e
parent649c173f8c6054f378a811701c168f02aba60e46
Respect SvLEN==0 and SvOOK in sv.c:sv_sethek

SvLEN==0 means this scalar does not own the buffer, so it should
not free it.

SvOOK means that SvPVX does not point to the start of the buffer
because we have cheated with s/...// or substr and not copied the
string back.

I don’t believe any such scalars currently make their way into
sv_sethek and get past the THINKFIRST check in that state, but we
should still play it safe.

SvPV_free handles both cases.
sv.c