Previously, the append functions in QConcatenable in the QStringBuilder
dereferenced the data() pointer of the argument QLatin1String without
performing null check.
Change-Id: I629f19fbce3113f1f80f4272fa7ae34e1dbc6bee
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
static int size(const QLatin1String a) { return a.size(); }
static inline void appendTo(const QLatin1String a, QChar *&out)
{
- for (const char *s = a.data(); *s; )
- *out++ = QLatin1Char(*s++);
+ if (a.data()) {
+ for (const char *s = a.data(); *s; )
+ *out++ = QLatin1Char(*s++);
+ }
}
static inline void appendTo(const QLatin1String a, char *&out)
{
- for (const char *s = a.data(); *s; )
- *out++ = *s++;
+ if (a.data()) {
+ for (const char *s = a.data(); *s; )
+ *out++ = *s++;
+ }
}
};
str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL);
QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL));
#endif
+
+ QString str2 = QString::fromUtf8(UTF8_LITERAL);
+ QString str2_e = QString::fromUtf8(UTF8_LITERAL);
+ const char * nullData = 0;
+ str2 += QLatin1String(nullData) P str2;
+ str2_e += QLatin1String("") P str2_e;
+ QCOMPARE(str2, str2_e);
}
//operator QByteArray +=