In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/95670bde8957add23fdad6b1c9da76ef317f788f?hp=17d155413b0e201ca149c3701d53539001559d4d>
- Log ----------------------------------------------------------------- commit 95670bde8957add23fdad6b1c9da76ef317f788f Author: Nicholas Clark <[email protected]> Date: Sun Feb 26 00:22:41 2012 +0100 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. M perl.c commit b24bc0958ea575493f4672819334c2b884f1e90d Author: Nicholas Clark <[email protected]> Date: Sat Feb 25 23:50:49 2012 +0100 Remove all the never used parameters from the macro validate_suid() Several parameters are unused in either remaining variant of the validate_suid() macro. The two variants which used the extra parameters were removed with suidperl by commit cc69b689ee7c2745 in Jan 2009. M perl.c ----------------------------------------------------------------------- Summary of changes: perl.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/perl.c b/perl.c index 104cac7..1737893 100644 --- a/perl.c +++ b/perl.c @@ -77,11 +77,9 @@ char *getenv (char *); /* Usually in <stdlib.h> */ static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen); #ifdef SETUID_SCRIPTS_ARE_SECURE_NOW -/* Drop everything. Heck, don't even try to call it */ -# define validate_suid(validarg, scriptname, fdscript, suidscript, linestr_sv, rsfp) NOOP +# define validate_suid(rsfp) NOOP #else -/* Drop almost everything */ -# define validate_suid(validarg, scriptname, fdscript, suidscript, linestr_sv, rsfp) S_validate_suid(aTHX_ rsfp) +# define validate_suid(rsfp) S_validate_suid(aTHX_ rsfp) #endif #define CALL_BODY_SUB(myop) \ @@ -1801,15 +1799,12 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) #ifdef USE_SITECUSTOMIZE bool minus_f = FALSE; #endif - SV *linestr_sv = newSV_type(SVt_PVIV); + SV *linestr_sv = NULL; bool add_read_e_script = FALSE; U32 lex_start_flags = 0; PERL_SET_PHASE(PERL_PHASE_START); - SvGROW(linestr_sv, 80); - sv_setpvs(linestr_sv,""); - init_main_stash(); { @@ -2080,8 +2075,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) lex_start_flags = LEX_DONT_CLOSE_RSFP; } - validate_suid(validarg, scriptname, fdscript, suidscript, - linestr_sv, rsfp); + validate_suid(rsfp); #ifndef PERL_MICRO # if defined(SIGCHLD) || defined(SIGCLD) @@ -2106,6 +2100,8 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) forbid_setid('x', suidscript); /* Hence you can't get here if suidscript is true */ + linestr_sv = newSV_type(SVt_PV); + lex_start_flags |= LEX_START_COPIED; find_beginning(linestr_sv, rsfp); if (cddir && PerlDir_chdir( (char *)cddir ) < 0) Perl_croak(aTHX_ "Can't chdir to %s",cddir); @@ -2234,6 +2230,9 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) #endif lex_start(linestr_sv, rsfp, lex_start_flags); + if(linestr_sv) + SvREFCNT_dec(linestr_sv); + PL_subname = newSVpvs("main"); if (add_read_e_script) -- Perl5 Master Repository
