diff --git a/libgnucash/engine/gncCustomer.c b/libgnucash/engine/gncCustomer.c index 6260b6c3b6..18192d234b 100644 --- a/libgnucash/engine/gncCustomer.c +++ b/libgnucash/engine/gncCustomer.c @@ -987,10 +987,13 @@ gncCustomerGetCachedBalance (GncCustomer *cust) void gncCustomerSetCachedBalance (GncCustomer *cust, const gnc_numeric *new_bal) { - if (!new_bal && cust->balance) + if (!new_bal) { - g_free (cust->balance); - cust->balance = NULL; + if (cust->balance) + { + g_free (cust->balance); + cust->balance = NULL; + } return; } diff --git a/libgnucash/engine/gncEmployee.c b/libgnucash/engine/gncEmployee.c index d398a307ab..8f57494052 100644 --- a/libgnucash/engine/gncEmployee.c +++ b/libgnucash/engine/gncEmployee.c @@ -962,10 +962,13 @@ gncEmployeeGetCachedBalance (GncEmployee *empl) void gncEmployeeSetCachedBalance (GncEmployee *empl, const gnc_numeric *new_bal) { - if (!new_bal && empl->balance) + if (!new_bal) { - g_free (empl->balance); - empl->balance = NULL; + if (empl->balance) + { + g_free (empl->balance); + empl->balance = NULL; + } return; } diff --git a/libgnucash/engine/gncVendor.c b/libgnucash/engine/gncVendor.c index 19f75ddc38..5f01a03145 100644 --- a/libgnucash/engine/gncVendor.c +++ b/libgnucash/engine/gncVendor.c @@ -1040,10 +1040,13 @@ gncVendorGetCachedBalance (GncVendor *vend) void gncVendorSetCachedBalance (GncVendor *vend, const gnc_numeric *new_bal) { - if (!new_bal && vend->balance) + if (!new_bal) { - g_free (vend->balance); - vend->balance = NULL; + if (vend->balance) + { + g_free (vend->balance); + vend->balance = NULL; + } return; }