diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-02 04:01:16 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-02 04:01:16 -0400 |
commit | 75363003bd080897e9705f8edd70066a191e95aa (patch) | |
tree | b156b5419f1caac197b8643e7060ee1af5c83fff /src/amount.cc | |
parent | 10df6621669ff8a2904512a7096808137d334f00 (diff) | |
download | fork-ledger-75363003bd080897e9705f8edd70066a191e95aa.tar.gz fork-ledger-75363003bd080897e9705f8edd70066a191e95aa.tar.bz2 fork-ledger-75363003bd080897e9705f8edd70066a191e95aa.zip |
Throw an exception if mpfr_asprintf fails
Diffstat (limited to 'src/amount.cc')
-rw-r--r-- | src/amount.cc | 5 |
1 files changed, 4 insertions, 1 deletions
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 << ")"); |