diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-18 16:31:13 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-10-19 17:44:05 +0200 |
commit | 229c9736bb7738ae181f2db3fa71623b5b3582fb (patch) | |
tree | b0c8373c2488bfdb469320d32ef72230ea2306b0 /src/corelib | |
parent | 9d2a107da2e5af77dece660b5d2b0958e79dc284 (diff) |
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 <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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; |