mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 798199 - Pasting invalid value in date column crashes GnuCash
Catch boost::gregorian::bad_year in LDT_from_struct_tm and rethrow std::invalid_argument for C wrappers to catch and handle.
This commit is contained in:
parent
66685f042e
commit
42213c597c
@ -254,6 +254,8 @@ LDT_from_date_daypart(const Date& date, DayPart part, const TZ_Ptr tz)
|
|||||||
|
|
||||||
static LDT
|
static LDT
|
||||||
LDT_from_struct_tm(const struct tm tm)
|
LDT_from_struct_tm(const struct tm tm)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Date tdate{boost::gregorian::date_from_tm(tm)};
|
Date tdate{boost::gregorian::date_from_tm(tm)};
|
||||||
Duration tdur{boost::posix_time::time_duration(tm.tm_hour, tm.tm_min,
|
Duration tdur{boost::posix_time::time_duration(tm.tm_hour, tm.tm_min,
|
||||||
@ -261,6 +263,11 @@ LDT_from_struct_tm(const struct tm tm)
|
|||||||
TZ_Ptr tz{tzp->get(tdate.year())};
|
TZ_Ptr tz{tzp->get(tdate.year())};
|
||||||
return LDT_from_date_time(tdate, tdur, tz);
|
return LDT_from_date_time(tdate, tdur, tz);
|
||||||
}
|
}
|
||||||
|
catch(const boost::gregorian::bad_year&)
|
||||||
|
{
|
||||||
|
throw(std::invalid_argument{"Time value is outside the supported year range."});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_set_tzp(TimeZoneProvider& new_tzp)
|
_set_tzp(TimeZoneProvider& new_tzp)
|
||||||
|
Loading…
Reference in New Issue
Block a user