summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-05-31 14:00:48 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-01 01:22:06 +0200
commitfbee9834dc0fa1838a38e552eddd941af1ef39ac (patch)
treead9db14e553a5026b6196073ce25f009b62ce391 /src/corelib
parent1e778ebd06c37f7a81e4247a5998d06fa849eff8 (diff)
Fix crash in QStringBuilder when concatenating data-less QLatin1String
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qstringbuilder.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 1f13d0da80..b3d47d2250 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -230,13 +230,17 @@ template <> struct QConcatenable<QLatin1String>
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++;
+ }
}
};