This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In S_parse_body(), don't "leak" linestr_sv until global destruction.
authorNicholas Clark <nick@ccl4.org>
Sat, 25 Feb 2012 23:22:41 +0000 (00:22 +0100)
committerNicholas Clark <nick@ccl4.org>
Sat, 17 Mar 2012 10:44:36 +0000 (11:44 +0100)
commit95670bde8957add23fdad6b1c9da76ef317f788f
tree137619fbd2e3682eaa104b1a04fac949478a64d9
parentb24bc0958ea575493f4672819334c2b884f1e90d
In S_parse_body(), don't "leak" linestr_sv until global destruction.

This commit ensures that linestr_sv is properly cleaned up, if allocated.

The local variable linestr_sv was added by commit 009d90df4e17a415 in 2007,
to replace use of PL_linestr in S_parse_body(). However, that commit didn't
add any code to free linestr_sv at the end of S_parse_body(), meaning that
the SV sticks around until global destruction.

Subsequent code simplification possible by the removal of suidperl reveals
that linestr_sv is only needed for the '-x' option, so it's safe to avoid
allocating it up front. Additionally, during '-x' processing, Perl_sv_gets()
will upgrade the target SV to SVt_PV and allocate the string buffer as needed,
so there's no need to pre-upgrade or pre-allocate the SV in S_parse_body().
This slightly reduces the amount of code.
perl.c