Avoid crash when committing a date outside of the valid range

Insert a NULL in its place.
This commit is contained in:
John Ralls 2018-03-15 16:28:01 -07:00
parent 9b8901248c
commit 74d94650ed

View File

@ -442,11 +442,18 @@ GncSqlColumnTableEntryImpl<CT_TIMESPEC>::add_to_query(QofIdTypeConst obj_name,
g_return_if_fail (ts_getter != NULL); g_return_if_fail (ts_getter != NULL);
ts = (*ts_getter) (pObject); ts = (*ts_getter) (pObject);
} }
if (ts.tv_sec > MINTIME && ts.tv_sec < MAXTIME)
{
GncDateTime time(ts.tv_sec); GncDateTime time(ts.tv_sec);
vec.emplace_back (std::make_pair (std::string{m_col_name}, vec.emplace_back (std::make_pair (std::string{m_col_name},
time.format_zulu ("'%Y-%m-%d %H:%M:%S'"))); time.format_zulu ("'%Y-%m-%d %H:%M:%S'")));
} }
else
{
vec.emplace_back (std::make_pair (std::string{m_col_name},
"NULL"));
}
}
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
#define DATE_COL_SIZE 8 #define DATE_COL_SIZE 8