From 229c9736bb7738ae181f2db3fa71623b5b3582fb Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 18 Sep 2020 16:31:13 +0200 Subject: Check time-text is long enough while checking for its colons Added some tests that trigger an assert without this check. (Drive-by: renamed one QTime test to match its QDate(Time)? counterparts.) Change-Id: I3d6767605fdcca13a9b4d43a32904f584eb57cf9 Reviewed-by: Thiago Macieira Reviewed-by: Andrei Golubev Reviewed-by: Andreas Buhr --- src/corelib/time/qdatetime.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 98b5dc8212..c1e56ced07 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -229,8 +229,10 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) QTime time; if (words.size() && words.at(0).contains(colon)) { const QStringView when = words.takeFirst(); - if (when[2] != colon || (when.size() == 8 ? when[5] != colon : when.size() > 5)) + if (when.size() < 5 || when[2] != colon + || (when.size() == 8 ? when[5] != colon : when.size() > 5)) { return result; + } const int hour = when.left(2).toInt(&ok); if (!ok) return result; -- cgit v1.2.3