From: Marcus Holland-Moritz Date: Thu, 28 Aug 2003 21:47:22 +0000 (+0200) Subject: Perl_newCONSTSUB() related memory leaks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5383bea48295157ec239aaa7b40cfb64d93bf734;p=p5sagit%2Fp5-mst-13.2.git Perl_newCONSTSUB() related memory leaks From: "Marcus Holland-Moritz" Message-ID: <006301c36d9d$335976a0$e400a8c0@R2D2> p4raw-id: //depot/perl@20930 --- diff --git a/op.c b/op.c index 6d3e312..a4b20e7 100644 --- a/op.c +++ b/op.c @@ -3796,6 +3796,8 @@ Perl_newLOOPEX(pTHX_ I32 type, OP *label) return o; } +static void const_sv_xsub(pTHX_ CV* cv); + /* =for apidoc cv_undef @@ -3811,8 +3813,9 @@ void Perl_cv_undef(pTHX_ CV *cv) { #ifdef USE_ITHREADS - if (CvFILE(cv) && !CvXSUB(cv)) { - /* for XSUBs CvFILE point directly to static memory; __FILE__ */ + if (CvFILE(cv) && (!CvXSUB(cv) || CvXSUB(cv) == const_sv_xsub)) { + /* for XSUBs CvFILE point directly to static memory; __FILE__ + * except when XSUB was constructed via newCONSTSUB() */ Safefree(CvFILE(cv)); } CvFILE(cv) = 0; @@ -3874,8 +3877,6 @@ Perl_cv_ckproto(pTHX_ CV *cv, GV *gv, char *p) } } -static void const_sv_xsub(pTHX_ CV* cv); - /* =head1 Optree Manipulation Functions @@ -4359,6 +4360,9 @@ Perl_newCONSTSUB(pTHX_ HV *stash, char *name, SV *sv) CvCONST_on(cv); sv_setpv((SV*)cv, ""); /* prototype is "" */ + if (stash) + CopSTASH_free(PL_curcop); + LEAVE; return cv;