diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-08-05 16:01:39 +0300 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-05 18:52:16 +0000 |
commit | 009f1f28120c473632d4a91d6a79c056ac2bbe6a (patch) | |
tree | 5dd48607dbe1e95367debfe7613c94b21acf4360 /src/corelib/tools | |
parent | 4b63ab9a93dfcdad5bdcce3aa437e16598233ca1 (diff) |
QString: fix regression comparing null QString with null const char *
Commit 4a40c717f3cf1ae181df49c91261a12d5e33e5a4 optimized
QString::compare_helper(QChar*, int, char*, int), but got
the case wrong where the rhs is null, but the lhs is empty,
not null (which is the case even with a null QString, as
QString().constData() != nullptr). The correct result in
this case is 0, since in Qt empty and null strings compare
equal.
Fix by checking the length of lhs, not its pointer.
Task-number: QTBUG-55154
Change-Id: I3ec2cd25d9bdca90cf3f5568a875b1e52c779979
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 87b222881c..7c4280d36b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5402,7 +5402,7 @@ int QString::compare_helper(const QChar *data1, int length1, const char *data2, Qt::CaseSensitivity cs) { if (!data2) - return int(bool(data1)); + return length1; if (Q_UNLIKELY(length2 < 0)) length2 = int(strlen(data2)); // ### make me nothrow in all cases |