From 75363003bd080897e9705f8edd70066a191e95aa Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 2 Jun 2010 04:01:16 -0400 Subject: [PATCH] Throw an exception if mpfr_asprintf fails --- src/amount.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/amount.cc b/src/amount.cc index 13f30755..1cba92f8 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -130,7 +130,10 @@ namespace { mpfr_set_prec(tempfb, bits + amount_t::extend_by_digits*8); mpfr_set_q(tempfb, quant, GMP_RNDN); - mpfr_asprintf(&buf, "%.*Rf", prec, tempfb); + if (mpfr_asprintf(&buf, "%.*Rf", prec, tempfb) < 0) + throw_(amount_error, + _("Cannot output amount to a floating-point representation")); + DEBUG("amount.convert", "mpfr_print = " << buf << " (precision " << prec << ")");