summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2020-08-11 10:46:38 +1000
committerSteve Hay <steve.m.hay@googlemail.com>2020-12-26 14:50:48 +0000
commitcd55a14f8579ba68f5f508018eafc559692b7a5e (patch)
treecf6c9c59c27e606a73807456dcbfa4ba34217ac3
parent1e63714900e7a528d0567ad241691c80439ffb9c (diff)
downloadperl-cd55a14f8579ba68f5f508018eafc559692b7a5e.tar.gz
make postav and valstr mortal so they're freed soonish
these can leak if the value being dumped (or any part of it) had get magic and that magic throws an exception. Several other SVs can also leak in that case, but cleaning those up is more complex. (cherry picked from commit b98a3a6d08f681353d0b357fd1cce437c93656e7)
-rw-r--r--dist/Data-Dumper/Dumper.xs5
1 files changed, 2 insertions, 3 deletions
diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs
index f91145adfa..d4b34addd4 100644
--- a/dist/Data-Dumper/Dumper.xs
+++ b/dist/Data-Dumper/Dumper.xs
@@ -1613,12 +1613,13 @@ Data_Dumper_Dumpxs(href, ...)
style.sortkeys = &PL_sv_yes;
}
postav = newAV();
+ sv_2mortal((SV*)postav);
if (todumpav)
imax = av_len(todumpav);
else
imax = -1;
- valstr = newSVpvs("");
+ valstr = newSVpvs_flags("", SVs_TEMP);
for (i = 0; i <= imax; ++i) {
SV *newapad;
@@ -1719,8 +1720,6 @@ Data_Dumper_Dumpxs(href, ...)
retval = newSVpvs_flags("", SVs_TEMP);
}
}
- SvREFCNT_dec(postav);
- SvREFCNT_dec(valstr);
/* we defer croaking until here so that temporary SVs and
* buffers won't be leaked */