diff options
author | Tony Cook <tony@develop-help.com> | 2017-02-09 11:19:45 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2017-02-09 11:21:30 +1100 |
commit | fb926b48abdbc7a4f69369fa58417a8620abe15c (patch) | |
tree | 9d3dd13ebe5558d6d2210a052aeeef9432dd73e5 /sv.c | |
parent | 61f45fbeb954464ff9f1342dbca22ddef0bce5b0 (diff) | |
download | perl-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); } |