mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Prevent potential nullptr dereference.
Found by clang static analyzer.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user