diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-06-27 11:09:23 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-06-27 14:30:55 (GMT) |
commit | b2e678bfd4f190ab27cb380201207d8f227f0739 (patch) | |
tree | 1830b50438d9a439a47322cb9412565e521d482e /src/corelib | |
parent | 2ff9617cd6093a758dddea5ce50d1efd6e98ded8 (diff) | |
download | Qt-b2e678bfd4f190ab27cb380201207d8f227f0739.zip Qt-b2e678bfd4f190ab27cb380201207d8f227f0739.tar.gz Qt-b2e678bfd4f190ab27cb380201207d8f227f0739.tar.bz2 |
QStringBuilder: do not crash with null char*
This is supported by the others operator+
Change-Id: I9a1d1a0afb63acf32935948111d43ca6da370363
Reviewed-on: http://codereview.qt.nokia.com/764
Reviewed-by: hjk
(cherry picked from commit 53a16752c257d2f4f99ecef2cde1580b817fc12a)
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qstringbuilder.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringbuilder.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 45de6bc..1cc7e5d 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -162,6 +162,8 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out } #endif if (len == -1) { + if (!a) + return; while (*a) *out++ = QLatin1Char(*a++); } else { diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 709d84a..594ab2f 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -352,6 +352,8 @@ template <> struct QConcatenable<const char *> : private QAbstractConcatenable #endif static inline void appendTo(const char *a, char *&out) { + if (!a) + return; while (*a) *out++ = *a++; } |