Skip to content

Commit

Permalink
Bug 798015 - cash flow numerical-overflow
Browse files Browse the repository at this point in the history
error is caused by pricedb containing an invalid gnc_numeric
price. multiplication of (invalid) price with amount causes a report
crash.

Fix: if invalid price, return zero for amount converted to report
currency.
  • Loading branch information
christopherlam committed Nov 22, 2020
1 parent 72982de commit d11bdb3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libgnucash/engine/gnc-pricedb.c
Expand Up @@ -2616,6 +2616,10 @@ static gnc_numeric convert_amount_at_date (GNCPriceDB *pdb,

price = gnc_pricedb_get_nearest_price (pdb, orig_currency, new_currency, t);

/* the price retrieved may be invalid. return zero. see 798015 */
if (gnc_numeric_check (price))
return gnc_numeric_zero ();

return gnc_numeric_mul
(amount, price, gnc_commodity_get_fraction (new_currency),
GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND);
Expand Down

0 comments on commit d11bdb3

Please sign in to comment.