Fix ICU's handling of last representable transition
ICU's search for next transition, when the result would lie later than is representable by qint64, returns the last transition before the bound, even if this is at the time it was meant to exclude from the range searched. This lead to infinite looping when we tried to traverse transitions forward. Recognize when this happens and return the invalid data object that indicates falling off the end of time instead. Task-number: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: I1a210fb7a4086b2fdb052b2260c800bfc29f965a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
57742f7728
commit
845eabb314
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 John Layt <jlayt@kde.org>
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Copyright (C) 2022 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
@ -207,6 +207,14 @@ static QTimeZonePrivate::Data ucalTimeZoneTransition(UCalendar *m_ucal,
|
||||
status = U_ZERO_ERROR;
|
||||
bool ok = ucal_getTimeZoneTransitionDate(ucal, type, &tranMSecs, &status);
|
||||
|
||||
// Catch a known violation (in ICU 67) of the specified behavior:
|
||||
if (U_SUCCESS(status) && ok && type == UCAL_TZ_TRANSITION_NEXT) {
|
||||
// At the end of time, that can "succeed" with tranMSecs ==
|
||||
// atMSecsSinceEpoch, which should be treated as a failure.
|
||||
// (At the start of time, previous correctly fails.)
|
||||
ok = qint64(tranMSecs) > atMSecsSinceEpoch;
|
||||
}
|
||||
|
||||
// Set the transition time to find the offsets for
|
||||
if (U_SUCCESS(status) && ok) {
|
||||
status = U_ZERO_ERROR;
|
||||
|
Loading…
x
Reference in New Issue
Block a user