diff options
author | Tony Cook <tony@develop-help.com> | 2020-08-10 16:26:30 +1000 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2020-12-26 14:50:37 +0000 |
commit | 1e63714900e7a528d0567ad241691c80439ffb9c (patch) | |
tree | 01f5fa24b5915294da2761ec2ffc83545ac0c1f6 | |
parent | 5a4edcc643697c4815b845635cc938c367a056fa (diff) | |
download | perl-1e63714900e7a528d0567ad241691c80439ffb9c.tar.gz |
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
(cherry picked from commit 41463160be4baa0d81d9d8297508a1b9bdcaa206)
-rw-r--r-- | dist/Data-Dumper/Dumper.xs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs index a324cb6429..f91145adfa 100644 --- a/dist/Data-Dumper/Dumper.xs +++ b/dist/Data-Dumper/Dumper.xs @@ -1541,7 +1541,7 @@ Data_Dumper_Dumpxs(href, ...) seenhv = NULL; name = sv_newmortal(); - retval = newSVpvs(""); + retval = newSVpvs_flags("", SVs_TEMP); if (SvROK(href) && (hv = (HV*)SvRV((SV*)href)) && SvTYPE(hv) == SVt_PVHV) { @@ -1714,9 +1714,9 @@ Data_Dumper_Dumpxs(href, ...) } SvPVCLEAR(valstr); if (gimme == G_ARRAY) { - XPUSHs(sv_2mortal(retval)); + XPUSHs(retval); if (i < imax) /* not the last time thro ? */ - retval = newSVpvs(""); + retval = newSVpvs_flags("", SVs_TEMP); } } SvREFCNT_dec(postav); @@ -1732,7 +1732,7 @@ Data_Dumper_Dumpxs(href, ...) else croak("Call to new() method failed to return HASH ref"); if (gimme != G_ARRAY) - XPUSHs(sv_2mortal(retval)); + XPUSHs(retval); } SV * |