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 <thiago.macieira@intel.com>
This commit is contained in:
parent
09bfc52dde
commit
b3dc0c13e8
@ -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
|
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())
|
if (lhs.isEmpty())
|
||||||
return lencmp(0, rhs.size());
|
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());
|
const auto l = std::min(lhs.size(), rhs.size());
|
||||||
int r = qstrncmp(lhs.data(), rhs.data(), l);
|
int r = qstrncmp(lhs.data(), rhs.data(), l);
|
||||||
return r ? r : lencmp(lhs.size(), rhs.size());
|
return r ? r : lencmp(lhs.size(), rhs.size());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user