From 8b1194edea390f5608526a7f15cc562a3f17656b Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 8 Jan 2021 13:48:51 +0100 Subject: Correct string comparison in Android's IANA ID matching code It used QString.compare() and assumed it was returning a bool true on equality, when it actually returns an int that compares to 0 as the given strings compare. So it should use compare() == 0. This fixes several of QTimeZone's blacklisted tests on Android and a crasher, which we dodged with a QSKIP. Added an id-comparison to a test. Gave two local variables more informative names, made an early return into a QSKIP so it explains itself. Fixes: QTBUG-89905 Fixes: QTBUG-69122 Fixes: QTBUG-69132 Fixes: QTBUG-87435 Change-Id: Icf18ed5a810143d6e65d36e34a70e82faac10b8e Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira Reviewed-by: Andrei Golubev (cherry picked from commit 6ee13db700eecd8dfed54a9ec2d1081b39511562) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/time/qtimezoneprivate_android.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp index fae9b84fa0..da82832455 100644 --- a/src/corelib/time/qtimezoneprivate_android.cpp +++ b/src/corelib/time/qtimezoneprivate_android.cpp @@ -113,7 +113,7 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) // The ID or display name of the zone we've got, if it looks like what we asked for: const auto match = [iana](const QJNIObjectPrivate &jname) -> QByteArray { const QString name = jname.toString(); - if (iana.compare(name, Qt::CaseInsensitive)) + if (iana.compare(name, Qt::CaseInsensitive) == 0) return name.toUtf8(); return QByteArray(); -- cgit v1.2.3