diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 50ad4370032..9af92941d6b 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1358,7 +1358,9 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, bool fixup) const if (year % 100 != year2digits && (isSet & YearSection2Digits)) { const QDate date = actualDate(isSet, calendar, defaultCenturyStart, year, year2digits, month, day, dayofweek); - if (!(isSet & YearSection)) { + if (!date.isValid()) { + state = Invalid; + } else if (!(isSet & YearSection)) { year = date.year(); } else { conflicts = true; diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 0174fff98df..77154cd4c71 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -1497,6 +1497,8 @@ void tst_QDate::fromStringFormat_data() << u"05-00206-21"_s << u"MM-yyyy-dd"_s << 1900 << QDate(); QTest::newRow("5digit year, back") << u"05-21-00206"_s << u"MM-dd-yyyy"_s << 1900 << QDate(); + QTest::newRow("non-leap-feb-29") // QTBUG-132115: should fail but not assert + << u"290215"_s << u"ddMMyy"_s << 1900 << QDate(); QTest::newRow("dash separator, no year at end") << u"05-21-"_s << u"dd-MM-yyyy"_s << 1900 << QDate();