From 7c350c3ae5ab014ecd611a518a7738fd8a46082b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 19 Sep 2022 18:06:26 -0700 Subject: [PATCH] Bug 798616 - Can't register amount greater than 9,000,000,000 Because when loading the value the split in the xml backend doesn't yet have a parent so the code tried to convert to GNC_COMMODITY_MAX_FRACTION and if the numerator was larger than 10^10 that would overflow. To fix it this changes the "don't know" response to get_currency_denom and get_commodity_denom to GNC_DENOM_AUTO which will normally leave the denominator alone. --- libgnucash/engine/Split.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c index 406ab86033..d8fc1b784e 100644 --- a/libgnucash/engine/Split.c +++ b/libgnucash/engine/Split.c @@ -1130,13 +1130,9 @@ xaccSplitDetermineGainStatus (Split *split) static inline int get_currency_denom(const Split * s) { - if (!s) + if (!(s && s->parent && s->parent->common_currency)) { - return 0; - } - else if (!s->parent || !s->parent->common_currency) - { - return GNC_COMMODITY_MAX_FRACTION; + return GNC_DENOM_AUTO; } else { @@ -1147,13 +1143,9 @@ get_currency_denom(const Split * s) static inline int get_commodity_denom(const Split * s) { - if (!s) - { - return 0; - } - else if (!s->acc) + if (!(s && s->acc)) { - return GNC_COMMODITY_MAX_FRACTION; + return GNC_DENOM_AUTO; } else {