From 56025cdefc07e30b025c65146affc141888b2f83 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 11 Jan 2019 16:25:02 -0800 Subject: Don't attempt to invert a value if it's already zero (#1703) --- src/amount.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/amount.cc') diff --git a/src/amount.cc b/src/amount.cc index 05145f87..c6463b2b 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -604,7 +604,9 @@ void amount_t::in_place_invert() throw_(amount_error, _("Cannot invert an uninitialized amount")); _dup(); - mpq_inv(MP(quantity), MP(quantity)); + + if (sign() != 0) + mpq_inv(MP(quantity), MP(quantity)); } void amount_t::in_place_round() -- cgit v1.2.3