summaryrefslogtreecommitdiff
path: root/src/corelib/time/qdatetime.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-23 21:06:47 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2023-03-23 21:06:47 +0200
commit42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (patch)
treea7f25b1d335a834a7c3ae104cee913ef3a4dd4fb /src/corelib/time/qdatetime.cpp
parent4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (diff)
parent168ff3419f256fdb35b586275d293fc0cd773fe1 (diff)
downloadqtbase-42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4.tar.gz
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl5.15
Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r--src/corelib/time/qdatetime.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index ec12569e3f..c30fd046a4 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -75,6 +75,7 @@
#include "qcalendar.h"
#include "qgregoriancalendar_p.h"
+#include "private/qnumeric_p.h"
QT_BEGIN_NAMESPACE
@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
if (isNull())
return QDate();
- // Due to limits on minJd() and maxJd() we know that any overflow
- // will be invalid and caught by fromJulianDay().
- return fromJulianDay(jd + ndays);
+ qint64 r;
+ if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
+ return QDate();
+ else
+ return fromJulianDay(r);
}
/*!
@@ -4548,9 +4551,9 @@ static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date,
QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;
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::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time),
- d->m_timeZone,
+ d.d->m_timeZone,
QDateTimePrivate::UnknownDaylightTime,
date, time);
#endif // timezone