summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r--src/corelib/tools/qbytearray.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 6be3416..f26d878 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -541,6 +541,11 @@ QByteArray qUncompress(const uchar* data, int nbytes)
forever {
ulong alloc = len;
+ if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ //QByteArray does not support that huge size anyway.
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+ }
QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc));
if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
@@ -556,6 +561,11 @@ QByteArray qUncompress(const uchar* data, int nbytes)
switch (res) {
case Z_OK:
if (len != alloc) {
+ if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ //QByteArray does not support that huge size anyway.
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+ }
QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len));
if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
@@ -904,6 +914,13 @@ QByteArray &QByteArray::operator=(const char *str)
return *this;
}
+/*! \fn void QByteArray::swap(QByteArray &other)
+ \since 4.8
+
+ Swaps byte array \a other with this byte array. This operation is very
+ fast and never fails.
+*/
+
/*! \fn int QByteArray::size() const
Returns the number of bytes in this byte array.
@@ -1816,7 +1833,7 @@ QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after)
return *this;
} else {
QByteArray copy(after);
- // ### optimise me
+ // ### optimize me
remove(pos, len);
return insert(pos, copy);
}
@@ -1857,7 +1874,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen)
}
}
-// ### optimise all other replace method, by offering
+// ### optimize all other replace method, by offering
// QByteArray::replace(const char *before, int blen, const char *after, int alen)
/*!