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;
|
GncOwnerType type;
|
||||||
GncGUID guid;
|
GncGUID guid;
|
||||||
GncOwner owner;
|
GncOwner owner;
|
||||||
GncGUID* pGuid = NULL;
|
GncGUID* pGuid = nullptr;
|
||||||
|
|
||||||
g_return_if_fail (sql_be != NULL);
|
g_return_if_fail (sql_be != nullptr);
|
||||||
g_return_if_fail (pObject != NULL);
|
g_return_if_fail (pObject != nullptr);
|
||||||
|
|
||||||
auto book = sql_be->book();
|
auto book = sql_be->book();
|
||||||
auto buf = std::string{m_col_name} + "_type";
|
auto buf = std::string{m_col_name} + "_type";
|
||||||
@ -70,13 +70,15 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::load (const GncSqlBackend* sql_be,
|
|||||||
type = static_cast<decltype(type)>(row.get_int_at_col (buf.c_str()));
|
type = static_cast<decltype(type)>(row.get_int_at_col (buf.c_str()));
|
||||||
buf = std::string{m_col_name} + "_guid";
|
buf = std::string{m_col_name} + "_guid";
|
||||||
auto val = row.get_string_at_col (buf.c_str());
|
auto val = row.get_string_at_col (buf.c_str());
|
||||||
string_to_guid (val.c_str(), &guid);
|
if (string_to_guid (val.c_str(), &guid))
|
||||||
pGuid = &guid;
|
pGuid = &guid;
|
||||||
}
|
}
|
||||||
catch (std::invalid_argument)
|
catch (std::invalid_argument)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (type == GNC_OWNER_NONE || pGuid == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -711,7 +711,7 @@ gnc_sql_slots_delete (GncSqlBackend* sql_be, const GncGUID* guid)
|
|||||||
col_table[guid_val_col];
|
col_table[guid_val_col];
|
||||||
GncGUID child_guid;
|
GncGUID child_guid;
|
||||||
auto val = row.get_string_at_col (table_row->name());
|
auto val = row.get_string_at_col (table_row->name());
|
||||||
(void)string_to_guid (val.c_str(), &child_guid);
|
if (string_to_guid (val.c_str(), &child_guid))
|
||||||
gnc_sql_slots_delete (sql_be, &child_guid);
|
gnc_sql_slots_delete (sql_be, &child_guid);
|
||||||
}
|
}
|
||||||
catch (std::invalid_argument)
|
catch (std::invalid_argument)
|
||||||
|
@ -338,7 +338,7 @@ GncSqlColumnTableEntryImpl<CT_GUID>::load (const GncSqlBackend* sql_be,
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(void)string_to_guid (str.c_str(), &guid);
|
if (string_to_guid (str.c_str(), &guid))
|
||||||
set_parameter(pObject, &guid, get_setter(obj_name), m_gobj_param_name);
|
set_parameter(pObject, &guid, get_setter(obj_name), m_gobj_param_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,12 +168,14 @@ public:
|
|||||||
{
|
{
|
||||||
GncGUID guid;
|
GncGUID guid;
|
||||||
auto val = row.get_string_at_col (m_col_name);
|
auto val = row.get_string_at_col (m_col_name);
|
||||||
(void)string_to_guid (val.c_str(), &guid);
|
if (string_to_guid (val.c_str(), &guid))
|
||||||
|
{
|
||||||
auto target = get_ref(&guid);
|
auto target = get_ref(&guid);
|
||||||
if (target != nullptr)
|
if (target != nullptr)
|
||||||
set_parameter (pObject, target, get_setter(obj_name),
|
set_parameter (pObject, target, get_setter(obj_name),
|
||||||
m_gobj_param_name);
|
m_gobj_param_name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (std::invalid_argument) {}
|
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);
|
auto val = row.get_string_at_col (m_col_name);
|
||||||
GncGUID guid;
|
GncGUID guid;
|
||||||
(void)string_to_guid (val.c_str(), &guid);
|
Transaction *tx = nullptr;
|
||||||
auto tx = xaccTransLookup (&guid, sql_be->book());
|
if (string_to_guid (val.c_str(), &guid))
|
||||||
|
tx = xaccTransLookup (&guid, sql_be->book());
|
||||||
|
|
||||||
// If the transaction is not found, try loading it
|
// If the transaction is not found, try loading it
|
||||||
if (tx == nullptr)
|
if (tx == nullptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user