summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-07-11 17:23:21 +0300
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-04 19:55:04 +0000
commit9c8a8e90a6514c23bcbeb14073a9d6bdd926d68b (patch)
treeee3eb949e59abd38bc2dcaad25b0847ab772a784 /src/corelib
parent35117590c8f4634ddfdbe75966dd43adeca69369 (diff)
QString: fix append(const QStringRef &str)
Use QStringRef::isNull instead of QStringRef::string() for validation. Non-NULL str.string() may yet leave us with a useless str.unicode(), which is the actual problem here; whereas !str.isNull() does really confirm that str.unicode() is sensible. Such test prevents situation like: const QString a; QString b; b.append(a); // b.isNull() == true b.append(QStringRef(&a)); // b.isNull() == false Auto test updated: create QStringRef from QString directly, without any condition. Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qstring.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b5119444b7..9aeec77632 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -9375,7 +9375,7 @@ QString &QString::append(const QStringRef &str)
{
if (str.string() == this) {
str.appendTo(this);
- } else if (str.string()) {
+ } else if (!str.isNull()) {
int oldSize = size();
resize(oldSize + str.size());
memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar));