gnucash maint: Bug 798616 - Can't register amount greater than 9, 000, 000, 000

John Ralls jralls at code.gnucash.org
Mon Sep 19 21:18:07 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/7c350c3a (commit)
	from  https://github.com/Gnucash/gnucash/commit/1752f1d1 (commit)



commit 7c350c3ae5ab014ecd611a518a7738fd8a46082b
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Sep 19 18:06:26 2022 -0700

    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.

diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c
index 406ab8603..d8fc1b784 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
     {



Summary of changes:
 libgnucash/engine/Split.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)



More information about the gnucash-changes mailing list