From 4db05007d72963c082f3ffdfcc7a68c1fb53c266 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 11 Jan 2022 15:01:22 +0100 Subject: Fix an assertion failure in massageAdjustedDateTime() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QDateTimeData &d it's passed is a copy that's about to be modified; before we do so, we haven't detached so its internals have a ref-count of two, contradicting an assertion in the non-const Data::operator->(); so just directly access d.d->m_timezone, since we know that spec == TimeZone implies !isShort(). Added test that triggered the assertion and now doesn't. Fixes: QTBUG-99668 Change-Id: I07321ad91be5adce524be18e4ab82eee7110dc6a Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 5d228beb520d92c985497fb43fa91d2920db6cb0) --- src/corelib/time/qdatetime.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index b80a59da6a..db803be4ab 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2021 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -4239,10 +4239,10 @@ static inline void massageAdjustedDateTime(QDateTimeData &d, QDate date, QTime t QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime; QDateTimePrivate::localMSecsToEpochMSecs(timeToMSecs(date, time), &status, &date, &time); #if QT_CONFIG(timezone) - } else if (spec == Qt::TimeZone && d->m_timeZone.isValid()) { + } else if (spec == Qt::TimeZone && d.d->m_timeZone.isValid()) { QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime; QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(date, time), - d->m_timeZone, &status, &date, &time); + d.d->m_timeZone, &status, &date, &time); #endif // timezone } setDateTime(d, date, time); -- cgit v1.2.3