gnucash maint: Fix misplaced try block that caused unhandled exception if year out of range.
John Ralls
jralls at code.gnucash.org
Fri May 25 12:19:21 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/5708707f (commit)
from https://github.com/Gnucash/gnucash/commit/5389aa22 (commit)
commit 5708707f6c30702e1382d1e528298ae0472c7360
Author: John Ralls <jralls at ceridwen.us>
Date: Fri May 25 09:18:06 2018 -0700
Fix misplaced try block that caused unhandled exception if year out of range.
diff --git a/libgnucash/engine/gnc-datetime.cpp b/libgnucash/engine/gnc-datetime.cpp
index d0958de..3328fa8 100644
--- a/libgnucash/engine/gnc-datetime.cpp
+++ b/libgnucash/engine/gnc-datetime.cpp
@@ -158,12 +158,16 @@ LDT_from_unix_local(const time64 time)
static LDT
LDT_from_struct_tm(const struct tm tm)
{
- auto tdate = boost::gregorian::date_from_tm(tm);
- auto tdur = boost::posix_time::time_duration(tm.tm_hour, tm.tm_min,
- tm.tm_sec, 0);
- auto tz = tzp.get(tdate.year());
+ Date tdate;
+ Duration tdur;
+ TZ_Ptr tz;
+
try
{
+ tdate = boost::gregorian::date_from_tm(tm);
+ tdur = boost::posix_time::time_duration(tm.tm_hour, tm.tm_min,
+ tm.tm_sec, 0);
+ tz = tzp.get(tdate.year());
LDT ldt(tdate, tdur, tz, LDTBase::EXCEPTION_ON_ERROR);
return ldt;
}
Summary of changes:
libgnucash/engine/gnc-datetime.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list