|
|
e2fcb2 |
From 65ec73b1bc79648a2daeb494552ce0b0b90348d7 Mon Sep 17 00:00:00 2001
|
|
|
e2fcb2 |
From: Tony Cook <tony@develop-help.com>
|
|
|
e2fcb2 |
Date: Mon, 10 Aug 2020 16:26:30 +1000
|
|
|
e2fcb2 |
Subject: [PATCH 1/3] Data::Dumper: don't leak the working retval
|
|
|
e2fcb2 |
MIME-Version: 1.0
|
|
|
e2fcb2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
e2fcb2 |
Content-Transfer-Encoding: 8bit
|
|
|
e2fcb2 |
|
|
|
e2fcb2 |
do this by mortalizing the SV on creation, rather than when we
|
|
|
e2fcb2 |
push it on the stack
|
|
|
e2fcb2 |
|
|
|
e2fcb2 |
Petr Písař: Ported to Data-Dumper-2.173 from
|
|
|
e2fcb2 |
41463160be4baa0d81d9d8297508a1b9bdcaa206 perl commit.
|
|
|
e2fcb2 |
|
|
|
e2fcb2 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
e2fcb2 |
---
|
|
|
e2fcb2 |
Dumper.xs | 8 ++++----
|
|
|
e2fcb2 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
e2fcb2 |
|
|
|
e2fcb2 |
diff --git a/Dumper.xs b/Dumper.xs
|
|
|
e2fcb2 |
index a324cb6..f91145a 100644
|
|
|
e2fcb2 |
--- a/Dumper.xs
|
|
|
e2fcb2 |
+++ b/Dumper.xs
|
|
|
e2fcb2 |
@@ -1541,7 +1541,7 @@ Data_Dumper_Dumpxs(href, ...)
|
|
|
e2fcb2 |
seenhv = NULL;
|
|
|
e2fcb2 |
name = sv_newmortal();
|
|
|
e2fcb2 |
|
|
|
e2fcb2 |
- retval = newSVpvs("");
|
|
|
e2fcb2 |
+ retval = newSVpvs_flags("", SVs_TEMP);
|
|
|
e2fcb2 |
if (SvROK(href)
|
|
|
e2fcb2 |
&& (hv = (HV*)SvRV((SV*)href))
|
|
|
e2fcb2 |
&& SvTYPE(hv) == SVt_PVHV) {
|
|
|
e2fcb2 |
@@ -1714,9 +1714,9 @@ Data_Dumper_Dumpxs(href, ...)
|
|
|
e2fcb2 |
}
|
|
|
e2fcb2 |
SvPVCLEAR(valstr);
|
|
|
e2fcb2 |
if (gimme == G_ARRAY) {
|
|
|
e2fcb2 |
- XPUSHs(sv_2mortal(retval));
|
|
|
e2fcb2 |
+ XPUSHs(retval);
|
|
|
e2fcb2 |
if (i < imax) /* not the last time thro ? */
|
|
|
e2fcb2 |
- retval = newSVpvs("");
|
|
|
e2fcb2 |
+ retval = newSVpvs_flags("", SVs_TEMP);
|
|
|
e2fcb2 |
}
|
|
|
e2fcb2 |
}
|
|
|
e2fcb2 |
SvREFCNT_dec(postav);
|
|
|
e2fcb2 |
@@ -1732,7 +1732,7 @@ Data_Dumper_Dumpxs(href, ...)
|
|
|
e2fcb2 |
else
|
|
|
e2fcb2 |
croak("Call to new() method failed to return HASH ref");
|
|
|
e2fcb2 |
if (gimme != G_ARRAY)
|
|
|
e2fcb2 |
- XPUSHs(sv_2mortal(retval));
|
|
|
e2fcb2 |
+ XPUSHs(retval);
|
|
|
e2fcb2 |
}
|
|
|
e2fcb2 |
|
|
|
e2fcb2 |
SV *
|
|
|
e2fcb2 |
--
|
|
|
e2fcb2 |
2.25.4
|
|
|
e2fcb2 |
|