summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorMarcus Holland-Moritz <mhx-perl@gmx.net>2003-08-28 23:47:22 +0200
committerJarkko Hietaniemi <jhi@iki.fi>2003-08-29 12:57:07 +0000
commit5383bea48295157ec239aaa7b40cfb64d93bf734 (patch)
treec624924d65c4b8f16b43be575f9c2f47142976c2 /op.c
parent1403d6bf1ee303dd613942fa2f6df0519a053ba6 (diff)
downloadperl-5383bea48295157ec239aaa7b40cfb64d93bf734.tar.gz
Perl_newCONSTSUB() related memory leaks
From: "Marcus Holland-Moritz" <mhx-perl@gmx.net> Message-ID: <006301c36d9d$335976a0$e400a8c0@R2D2> p4raw-id: //depot/perl@20930
Diffstat (limited to 'op.c')
-rw-r--r--op.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/op.c b/op.c
index 6d3e312c14..a4b20e7c15 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;