path: root/src
diff options
authorMarc Mutz <>2019-08-24 06:47:41 +0200
committerMarc Mutz <>2019-08-25 17:37:52 +0200
commitb3dc0c13e88f3bd859c96144a9d4280c675665bc (patch)
tree9f437c19d4e70e65555e5b7d8a6cd19231e8f207 /src
parent09bfc52dde56cd525cfad4437b26ab534f72a86c (diff)
Fix assertion on passing nullptr QLatin1Strings to qt_compare_strings
qstrnicmp() has an assertion that the lhs string is not nullptr. Fix by moving the length check back to the front, regardless of cs's value. Amends cad7100fda1b27ba56c4d9efc6bceba62859dfbc. Change-Id: I31f808936c8dc6fbb10a70a59923746ef3e675e9 Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src')
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 4852d20082..ad2e8bbcd8 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1199,10 +1199,10 @@ static int qt_compare_strings(QLatin1String lhs, QStringView rhs, Qt::CaseSensit
static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
- if (cs == Qt::CaseInsensitive)
- return qstrnicmp(, lhs.size(),, rhs.size());
if (lhs.isEmpty())
return lencmp(0, rhs.size());
+ if (cs == Qt::CaseInsensitive)
+ return qstrnicmp(, lhs.size(),, rhs.size());
const auto l = std::min(lhs.size(), rhs.size());
int r = qstrncmp(,, l);
return r ? r : lencmp(lhs.size(), rhs.size());