From b3dc0c13e88f3bd859c96144a9d4280c675665bc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 24 Aug 2019 06:47:41 +0200 Subject: 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 --- src/corelib/tools/qstring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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.data(), lhs.size(), rhs.data(), rhs.size()); if (lhs.isEmpty()) return lencmp(0, rhs.size()); + if (cs == Qt::CaseInsensitive) + return qstrnicmp(lhs.data(), lhs.size(), rhs.data(), rhs.size()); const auto l = std::min(lhs.size(), rhs.size()); int r = qstrncmp(lhs.data(), rhs.data(), l); return r ? r : lencmp(lhs.size(), rhs.size()); -- cgit v1.2.3