In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/fb926b48abdbc7a4f69369fa58417a8620abe15c?hp=61f45fbeb954464ff9f1342dbca22ddef0bce5b0>

- Log -----------------------------------------------------------------
commit fb926b48abdbc7a4f69369fa58417a8620abe15c
Author: Tony Cook <[email protected]>
Date:   Thu Feb 9 11:19:45 2017 +1100

    (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.
-----------------------------------------------------------------------

Summary of changes:
 sv.c   | 5 ++++-
 util.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 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);
                 }
diff --git a/util.c b/util.c
index efe4c02b63..a822969503 100644
--- a/util.c
+++ b/util.c
@@ -5238,8 +5238,11 @@ Perl_my_snprintf(char *buffer, const Size_t len, const 
char *format, ...)
         if (qfmt) {
             /* If the format looked promising, use it as quadmath. */
             retval = quadmath_snprintf(buffer, len, qfmt, va_arg(ap, NV));
-            if (retval == -1)
+            if (retval == -1) {
+                if (qfmt != format)
+                    SAVEFREEPV(qfmt);
                 Perl_croak_nocontext("panic: quadmath_snprintf failed, format 
\"%s\"", qfmt);
+            }
             quadmath_valid = TRUE;
             if (qfmt != format)
                 Safefree(qfmt);

--
Perl5 Master Repository

Reply via email to