else CLEAR_ARGARRAY(av);
}
- /* protect @_ during save stack unwind. We donate this
- * refcount later to the calleeās pad for the non-XS case;
- * otherwise we decrement it later. */
- SvREFCNT_inc_simple_void(arg);
+ /* protect @_ during save stack unwind. */
+ if (arg)
+ SvREFCNT_inc_NN(sv_2mortal(MUTABLE_SV(arg)));
assert(PL_scopestack_ix == cx->blk_oldscopesp);
oldsave = PL_scopestack[cx->blk_oldscopesp - 1];
* our precious cv. See bug #99850. */
if (!CvROOT(cv) && !CvXSUB(cv)) {
const GV * const gv = CvGV(cv);
- SvREFCNT_dec(arg);
if (gv) {
SV * const tmpstr = sv_newmortal();
gv_efullname3(tmpstr, gv, NULL);
}
}
SP += items;
- SvREFCNT_dec(arg);
if (CxTYPE(cx) == CXt_SUB && CxHASARGS(cx)) {
/* Restore old @_ */
POP_SAVEARRAY();
if (arg) {
SvREFCNT_dec(PAD_SVl(0));
PAD_SVl(0) = (SV *)arg;
+ SvREFCNT_inc_simple_void_NN(arg);
}
/* GvAV(PL_defgv) might have been modified on scope
SvREFCNT_dec(av);
}
}
- else SvREFCNT_dec(arg);
+
if (PERLDB_SUB) { /* Checking curstash breaks DProf. */
Perl_get_db_sub(aTHX_ NULL, cv);
if (PERLDB_GOTO) {
use Config;
-plan tests => 130;
+plan tests => 131;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
::leak(5,0, \&g, "MG_SET");
}
+
+# check that @_ isn't leaked when dieing while goto'ing a new sub
+
+{
+ package my_goto;
+ sub TIEARRAY { bless [] }
+ sub FETCH { 1 }
+ sub STORE { die if $_[0][0]; $_[0][0] = 1 }
+
+ sub f { eval { g() } }
+ sub g {
+ my @a;
+ tie @a, "my_goto";
+ local $a[0];
+ goto &h;
+ }
+ sub h {}
+
+ ::leak(5, 0, \&f, q{goto shouldn't leak @_});
+}