From 54d012c665eb635f1e4fac1f1ec5aba1229ad9ca Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 21 Jan 2009 11:25:42 +0000 Subject: [PATCH] Change 28063 should have removed the call to savepvn() from Perl_newCONSTSUB() completely when it moved the allocation logic inside Perl_newXS_flags(). Whilst Rafael's fix in 29107 correctly plugged my leak, this commit is the actual correction. (Commits 77004dee2553ce034a8a58b2b2849e3656df46c3 and c3db7d9213b09a5852dab00368488f63a7625b9e respectively) --- op.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/op.c b/op.c index d80aa95..444ee3b 100644 --- a/op.c +++ b/op.c @@ -5959,14 +5959,11 @@ Perl_newCONSTSUB(pTHX_ HV *stash, const char *name, SV *sv) dVAR; CV* cv; #ifdef USE_ITHREADS - const char *const temp_p = CopFILE(PL_curcop); - const STRLEN len = temp_p ? strlen(temp_p) : 0; + const char *const file = CopFILE(PL_curcop); #else SV *const temp_sv = CopFILESV(PL_curcop); - STRLEN len; - const char *const temp_p = temp_sv ? SvPV_const(temp_sv, len) : NULL; + const char *const file = temp_sv ? SvPV_const_nolen(temp_sv) : NULL; #endif - char *const file = savepvn(temp_p, temp_p ? len : 0); ENTER; @@ -5994,10 +5991,10 @@ Perl_newCONSTSUB(pTHX_ HV *stash, const char *name, SV *sv) and so doesn't get free()d. (It's expected to be from the C pre- processor __FILE__ directive). But we need a dynamically allocated one, and we need it to get freed. */ - cv = newXS_flags(name, const_sv_xsub, file, "", XS_DYNAMIC_FILENAME); + cv = newXS_flags(name, const_sv_xsub, file ? file : "", "", + XS_DYNAMIC_FILENAME); CvXSUBANY(cv).any_ptr = sv; CvCONST_on(cv); - Safefree(file); #ifdef USE_ITHREADS if (stash) -- 1.8.3.1