summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-27 18:28:12 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-27 18:28:12 +0100
commitce6990c3e742e0833df0561246554cf07a888efb (patch)
tree412380582040f5bb314eb90ae029b41a883aa439 /src/corelib/tools/qbytearray.cpp
parent09e674849a40f5eb7e9f95fd2a952c621aec86d1 (diff)
parentfa9bde7d3a12ede956339c570f7b32f95d231e57 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r--src/corelib/tools/qbytearray.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 36acfc4c09..26bf7d047d 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -3644,7 +3644,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();
@@ -3682,8 +3682,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;
}