Prevent potential nullptr dereference.

Found by clang static analyzer.
This commit is contained in:
John Ralls
2018-11-28 15:36:06 +09:00
parent faba7975ac
commit 606d9cfee6
3 changed files with 18 additions and 9 deletions

View File

@@ -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;
}