Change 22373 by davem@davem-percy on 2004/02/24 23:25:52
[perl #26959] fix memory leak in @_ = ...; goto &sub
Affected files ...
... //depot/perl/pp_ctl.c#384 edit
Differences ...
==== //depot/perl/pp_ctl.c#384 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#383~22369~ Tue Feb 24 11:53:51 2004
+++ perl/pp_ctl.c Tue Feb 24 15:25:52 2004
@@ -2182,6 +2182,7 @@
char *label;
int do_dump = (PL_op->op_type == OP_DUMP);
static char must_have_label[] = "goto must have label";
+ AV *oldav = Nullav;
label = 0;
if (PL_op->op_flags & OPf_STACKED) {
@@ -2242,7 +2243,7 @@
GvAV(PL_defgv) = cx->blk_sub.savearray;
/* abandon @_ if it got reified */
if (AvREAL(av)) {
- (void)sv_2mortal((SV*)av); /* delay until return */
+ oldav = av; /* delay until return */
av = newAV();
av_extend(av, items-1);
AvFLAGS(av) = AVf_REIFY;
@@ -2268,6 +2269,9 @@
/* Now do some callish stuff. */
SAVETMPS;
+ /* For reified @_, delay freeing till return from new sub */
+ if (oldav)
+ SAVEFREESV((SV*)oldav);
SAVEFREESV(cv); /* later, undo the 'avoid premature free' hack */
if (CvXSUB(cv)) {
#ifdef PERL_XSUB_OLDSTYLE
End of Patch.