diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 9638c5b5e8..9690c8c66b 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1227,9 +1227,10 @@ 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); + if (qint64 r; Q_UNLIKELY(qAddOverflow(jd, ndays, &r))) + return QDate(); + else + return fromJulianDay(r); } /*!