mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[SQL] Check return of string_to_guid, bail if false.
This commit is contained in:
parent
d17c24b770
commit
04642fc42a
@ -58,10 +58,10 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::load (const GncSqlBackend* sql_be,
|
||||
GncOwnerType type;
|
||||
GncGUID guid;
|
||||
GncOwner owner;
|
||||
GncGUID* pGuid = NULL;
|
||||
GncGUID* pGuid = nullptr;
|
||||
|
||||
g_return_if_fail (sql_be != NULL);
|
||||
g_return_if_fail (pObject != NULL);
|
||||
g_return_if_fail (sql_be != nullptr);
|
||||
g_return_if_fail (pObject != nullptr);
|
||||
|
||||
auto book = sql_be->book();
|
||||
auto buf = std::string{m_col_name} + "_type";
|
||||
@ -70,14 +70,16 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::load (const GncSqlBackend* sql_be,
|
||||
type = static_cast<decltype(type)>(row.get_int_at_col (buf.c_str()));
|
||||
buf = std::string{m_col_name} + "_guid";
|
||||
auto val = row.get_string_at_col (buf.c_str());
|
||||
string_to_guid (val.c_str(), &guid);
|
||||
pGuid = &guid;
|
||||
if (string_to_guid (val.c_str(), &guid))
|
||||
pGuid = &guid;
|
||||
}
|
||||
catch (std::invalid_argument)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == GNC_OWNER_NONE || pGuid == nullptr)
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
|
@ -711,8 +711,8 @@ gnc_sql_slots_delete (GncSqlBackend* sql_be, const GncGUID* guid)
|
||||
col_table[guid_val_col];
|
||||
GncGUID child_guid;
|
||||
auto val = row.get_string_at_col (table_row->name());
|
||||
(void)string_to_guid (val.c_str(), &child_guid);
|
||||
gnc_sql_slots_delete (sql_be, &child_guid);
|
||||
if (string_to_guid (val.c_str(), &child_guid))
|
||||
gnc_sql_slots_delete (sql_be, &child_guid);
|
||||
}
|
||||
catch (std::invalid_argument)
|
||||
{
|
||||
|
@ -338,8 +338,8 @@ GncSqlColumnTableEntryImpl<CT_GUID>::load (const GncSqlBackend* sql_be,
|
||||
{
|
||||
return;
|
||||
}
|
||||
(void)string_to_guid (str.c_str(), &guid);
|
||||
set_parameter(pObject, &guid, get_setter(obj_name), m_gobj_param_name);
|
||||
if (string_to_guid (str.c_str(), &guid))
|
||||
set_parameter(pObject, &guid, get_setter(obj_name), m_gobj_param_name);
|
||||
}
|
||||
|
||||
template<> void
|
||||
|
@ -168,11 +168,13 @@ public:
|
||||
{
|
||||
GncGUID guid;
|
||||
auto val = row.get_string_at_col (m_col_name);
|
||||
(void)string_to_guid (val.c_str(), &guid);
|
||||
auto target = get_ref(&guid);
|
||||
if (target != nullptr)
|
||||
set_parameter (pObject, target, get_setter(obj_name),
|
||||
m_gobj_param_name);
|
||||
if (string_to_guid (val.c_str(), &guid))
|
||||
{
|
||||
auto target = get_ref(&guid);
|
||||
if (target != nullptr)
|
||||
set_parameter (pObject, target, get_setter(obj_name),
|
||||
m_gobj_param_name);
|
||||
}
|
||||
}
|
||||
catch (std::invalid_argument) {}
|
||||
}
|
||||
|
@ -1308,8 +1308,9 @@ GncSqlColumnTableEntryImpl<CT_TXREF>::load (const GncSqlBackend* sql_be,
|
||||
{
|
||||
auto val = row.get_string_at_col (m_col_name);
|
||||
GncGUID guid;
|
||||
(void)string_to_guid (val.c_str(), &guid);
|
||||
auto tx = xaccTransLookup (&guid, sql_be->book());
|
||||
Transaction *tx = nullptr;
|
||||
if (string_to_guid (val.c_str(), &guid))
|
||||
tx = xaccTransLookup (&guid, sql_be->book());
|
||||
|
||||
// If the transaction is not found, try loading it
|
||||
if (tx == nullptr)
|
||||
|
Loading…
Reference in New Issue
Block a user