Skip to content

Commit 4146316

Browse files
tonycozkhwilliamson
authored andcommitted
Data::Dumper: don't leak the working retval
do this by mortalizing the SV on creation, rather than when we push it on the stack
1 parent 33f8ca0 commit 4146316

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dist/Data-Dumper/Dumper.xs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ Data_Dumper_Dumpxs(href, ...)
15411541
seenhv = NULL;
15421542
name = sv_newmortal();
15431543

1544-
retval = newSVpvs("");
1544+
retval = newSVpvs_flags("", SVs_TEMP);
15451545
if (SvROK(href)
15461546
&& (hv = (HV*)SvRV((SV*)href))
15471547
&& SvTYPE(hv) == SVt_PVHV) {
@@ -1714,9 +1714,9 @@ Data_Dumper_Dumpxs(href, ...)
17141714
}
17151715
SvPVCLEAR(valstr);
17161716
if (gimme == G_ARRAY) {
1717-
XPUSHs(sv_2mortal(retval));
1717+
XPUSHs(retval);
17181718
if (i < imax) /* not the last time thro ? */
1719-
retval = newSVpvs("");
1719+
retval = newSVpvs_flags("", SVs_TEMP);
17201720
}
17211721
}
17221722
SvREFCNT_dec(postav);
@@ -1732,7 +1732,7 @@ Data_Dumper_Dumpxs(href, ...)
17321732
else
17331733
croak("Call to new() method failed to return HASH ref");
17341734
if (gimme != G_ARRAY)
1735-
XPUSHs(sv_2mortal(retval));
1735+
XPUSHs(retval);
17361736
}
17371737

17381738
SV *

0 commit comments

Comments
 (0)