mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Guard against some possible null pointer dereferences
Found by gcc 12 when compiling with "-O2 -Wnull-dereference"
This commit is contained in:
parent
7d5154ce18
commit
329a2f7d42
@ -121,7 +121,7 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
|
||||
case KvpValue::Type::GUID:
|
||||
{
|
||||
auto tempguid = val->get<GncGUID*>();
|
||||
return gnc_guid2scm(*tempguid);
|
||||
return tempguid ? gnc_guid2scm(*tempguid) : SCM_BOOL_F;
|
||||
}
|
||||
break;
|
||||
case KvpValue::Type::FRAME:
|
||||
@ -133,7 +133,7 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
|
||||
auto val_scm { gnc_kvp_value_ptr_to_scm (iter.second) };
|
||||
return scm_acons (key_scm, val_scm, rv);
|
||||
};
|
||||
return scm_reverse (std::accumulate (frame->begin(), frame->end(), SCM_EOL, acc));
|
||||
return frame ? scm_reverse (std::accumulate (frame->begin(), frame->end(), SCM_EOL, acc)) : SCM_BOOL_F;
|
||||
}
|
||||
break;
|
||||
case KvpValue::Type::GLIST:
|
||||
|
@ -230,7 +230,9 @@ editable_enters (GNCSearchCoreType *fe)
|
||||
void
|
||||
gnc_search_core_register_type (const char *type_name, GNCSearchCoreNew fcn)
|
||||
{
|
||||
g_return_if_fail (type_name || *type_name || fcn);
|
||||
g_return_if_fail (type_name);
|
||||
g_return_if_fail (*type_name);
|
||||
g_return_if_fail (fcn);
|
||||
g_return_if_fail (typeTable);
|
||||
|
||||
g_hash_table_insert (typeTable, (char *) type_name, (gpointer) fcn);
|
||||
|
@ -932,7 +932,11 @@ static int build_owner_report (GncOwner *owner, Account *acc)
|
||||
args = scm_cons (SCM_BOOL_F, args);
|
||||
}
|
||||
|
||||
arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery("_p__gncOwner"), 0);
|
||||
swig_type_info * qtype = SWIG_TypeQuery("_p__gncOwner");
|
||||
g_return_val_if_fail (qtype, -1);
|
||||
|
||||
arg = SWIG_NewPointerObj(owner, qtype, 0);
|
||||
|
||||
g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
|
||||
args = scm_cons (arg, args);
|
||||
|
||||
|
@ -411,6 +411,9 @@ gnc_get_optiondb_from_dispatcher(SCM dispatcher)
|
||||
else
|
||||
c_ptr = reinterpret_cast<void*>(SCM_CELL_WORD_1(smob));
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
auto u_ptr{static_cast<std::unique_ptr<GncOptionDB>*>(c_ptr)};
|
||||
return u_ptr->get();
|
||||
}
|
||||
|
@ -612,8 +612,11 @@ parse_string (var_store_ptr value, const char *string, parser_env_ptr pe)
|
||||
var_store_ptr val;
|
||||
|
||||
val = pop (pe);
|
||||
pe->negate_numeric (val->value);
|
||||
push (val, pe);
|
||||
if (val)
|
||||
{
|
||||
pe->negate_numeric (val->value);
|
||||
push (val, pe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -731,6 +731,8 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year,
|
||||
/* today's date */
|
||||
gnc_time (&secs);
|
||||
now = gnc_localtime (&secs);
|
||||
if (!now)
|
||||
return FALSE;
|
||||
now_day = now->tm_mday;
|
||||
now_month = now->tm_mon + 1;
|
||||
now_year = now->tm_year + 1900;
|
||||
|
@ -1208,7 +1208,8 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
|
||||
break;
|
||||
}
|
||||
|
||||
retval->search_for = search_for;
|
||||
if (retval)
|
||||
retval->search_for = search_for;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user