From fc3402ca823b74d1a642753c4cc8bef931411ab7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 25 Nov 2014 14:33:49 +0100 Subject: Clarify QString::clear() QString::clear() sets the string to the null QString, not just an empty one. Change-Id: Ie6f070f9f2e464105a7b87376e6dad90b5e4d2f2 Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qstring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 29b546770c..9921d5cfbb 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1692,9 +1692,9 @@ void QString::expand(int i) /*! \fn void QString::clear() - Clears the contents of the string and makes it empty. + Clears the contents of the string and makes it null. - \sa resize(), isEmpty() + \sa resize(), isNull() */ /*! \fn QString &QString::operator=(const QString &other) -- cgit v1.2.3 From c6aa76122e209350b8a7b3cb8b5bc8127a3722e7 Mon Sep 17 00:00:00 2001 From: Benjamin Lutz Date: Mon, 16 Sep 2013 14:37:34 +0200 Subject: Fix size miscalculation in QByteArray::toBase64 The size calculation in QByteArray::toBase64 overcalculates the size required for the output by up to 3 Bytes. This is fixed, which also implies that truncate() at the end is needed only if OmitTrailingEquals is used. Task-number: QTBUG-32436 Change-Id: I92a893047e7aca027c4aa0a6655bcca514585ff5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index a622221bd3..6ac442d27b 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -3571,7 +3571,7 @@ QByteArray QByteArray::toBase64(Base64Options options) const const char padchar = '='; int padlen = 0; - QByteArray tmp((d->size * 4) / 3 + 3, Qt::Uninitialized); + QByteArray tmp((d->size + 2) / 3 * 4, Qt::Uninitialized); int i = 0; char *out = tmp.data(); @@ -3609,8 +3609,9 @@ QByteArray QByteArray::toBase64(Base64Options options) const *out++ = alphabet[m]; } } - - tmp.truncate(out - tmp.data()); + Q_ASSERT((options & OmitTrailingEquals) || (out == tmp.size() + tmp.data())); + if (options & OmitTrailingEquals) + tmp.truncate(out - tmp.data()); return tmp; } -- cgit v1.2.3