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)
|
void gncCustomerSetCachedBalance (GncCustomer *cust, const gnc_numeric *new_bal)
|
||||||
{
|
{
|
||||||
if (!new_bal && cust->balance)
|
if (!new_bal)
|
||||||
{
|
{
|
||||||
g_free (cust->balance);
|
if (cust->balance)
|
||||||
cust->balance = NULL;
|
{
|
||||||
|
g_free (cust->balance);
|
||||||
|
cust->balance = NULL;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -962,10 +962,13 @@ gncEmployeeGetCachedBalance (GncEmployee *empl)
|
|||||||
|
|
||||||
void gncEmployeeSetCachedBalance (GncEmployee *empl, const gnc_numeric *new_bal)
|
void gncEmployeeSetCachedBalance (GncEmployee *empl, const gnc_numeric *new_bal)
|
||||||
{
|
{
|
||||||
if (!new_bal && empl->balance)
|
if (!new_bal)
|
||||||
{
|
{
|
||||||
g_free (empl->balance);
|
if (empl->balance)
|
||||||
empl->balance = NULL;
|
{
|
||||||
|
g_free (empl->balance);
|
||||||
|
empl->balance = NULL;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1040,10 +1040,13 @@ gncVendorGetCachedBalance (GncVendor *vend)
|
|||||||
|
|
||||||
void gncVendorSetCachedBalance (GncVendor *vend, const gnc_numeric *new_bal)
|
void gncVendorSetCachedBalance (GncVendor *vend, const gnc_numeric *new_bal)
|
||||||
{
|
{
|
||||||
if (!new_bal && vend->balance)
|
if (!new_bal)
|
||||||
{
|
{
|
||||||
g_free (vend->balance);
|
if (vend->balance)
|
||||||
vend->balance = NULL;
|
{
|
||||||
|
g_free (vend->balance);
|
||||||
|
vend->balance = NULL;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user