From 1119cd4ece6555be82212b273d05d581bffb79d1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 21 Mar 2019 16:10:09 +0100 Subject: [PATCH] Correct a misguided assertion in QTzTimeZonePrivate Without ICU, the TZ-DB backend for time-zones tripped over an assertion when running tst_QTimeZone::stressTest(), which happened to probe a zone between its last transition and the first transition of a POSIX rule that followed it. The code assumed there was no interval between these two; apparently, there can be. Change-Id: I3d0ad41fec0a255db2f9bfac54d33aa9b83938e8 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index bed62a02bd9..fa4ec031fae 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -1022,8 +1022,10 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs [beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch < beforeMSecsSinceEpoch; }); - Q_ASSERT(it > posixTrans.cbegin()); - return *--it; + if (it > posixTrans.cbegin()) + return *--it; + // else: it fell between the last transition and the first of the POSIX rule. + return dataForTzTransition(m_tranTimes.last()); } // Otherwise if we can find a valid tran then use its rule