summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-02-09 11:19:45 +1100
committerTony Cook <tony@develop-help.com>2017-02-09 11:21:30 +1100
commitfb926b48abdbc7a4f69369fa58417a8620abe15c (patch)
tree9d3dd13ebe5558d6d2210a052aeeef9432dd73e5 /sv.c
parent61f45fbeb954464ff9f1342dbca22ddef0bce5b0 (diff)
downloadperl-fb926b48abdbc7a4f69369fa58417a8620abe15c.tar.gz
(perl #126203) avoid potential leaks on quadmath_snprintf() failure
In the unlikely case quadmath_snprintf() fails both sv_vcatpvfn_flags() and my_snprintf() could leak the temp format string returned by quadmath_format_single() if quadmath_format_single() had to rebuild the format. Getting quadmath_snprintf() to fail in this context seems impractical, but future changes may make it happen, so clean up after ourselves.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index 339fa1b7d3..61bf3e10c9 100644
--- a/sv.c
+++ b/sv.c
@@ -12881,8 +12881,11 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
Perl_croak_nocontext("panic: quadmath invalid format \"%s\"", ptr);
elen = quadmath_snprintf(PL_efloatbuf, PL_efloatsize,
qfmt, nv);
- if ((IV)elen == -1)
+ if ((IV)elen == -1) {
+ if (qfmt != qptr)
+ SAVEFREEPV(qfmt);
Perl_croak_nocontext("panic: quadmath_snprintf failed, format \"%s\"", qfmt);
+ }
if (qfmt != ptr)
Safefree(qfmt);
}