From: Martin Liska Date: Fri, 3 Feb 2017 08:20:57 +0000 (+0100) Subject: Fix memory leaks in gimple-ssa-sprintf.c (PR tree-optimization/79339). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a95c7e2c93a8d750447fd6ee39a25ed47ca1370;p=gcc.git Fix memory leaks in gimple-ssa-sprintf.c (PR tree-optimization/79339). 2017-02-03 Martin Liska PR tree-optimization/79339 * gimple-ssa-sprintf.c (format_floating_max): Call mpfr_clear. (format_floating): Likewise. From-SVN: r245146 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d8bf2b4339..2118c339711 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-02-03 Martin Liska + + PR tree-optimization/79339 + * gimple-ssa-sprintf.c (format_floating_max): Call mpfr_clear. + (format_floating): Likewise. + 2017-02-03 Martin Liska PR ipa/79337 diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 9e099f0a133..10c6d8e9719 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -1501,7 +1501,10 @@ format_floating_max (tree type, char spec, HOST_WIDE_INT prec) mpfr_from_real (x, &rv, GMP_RNDN); /* Return a value one greater to account for the leading minus sign. */ - return 1 + get_mpfr_format_length (x, "", prec, spec, 'D'); + unsigned HOST_WIDE_INT r + = 1 + get_mpfr_format_length (x, "", prec, spec, 'D'); + mpfr_clear (x); + return r; } /* Return a range representing the minimum and maximum number of bytes @@ -1739,6 +1742,7 @@ format_floating (const directive &dir, tree arg) of the result struct. */ *minmax[i] = get_mpfr_format_length (mpfrval, fmtstr, prec[i], dir.specifier, rndspec); + mpfr_clear (mpfrval); } }