diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2010-11-23 11:26:54 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2010-11-23 11:26:54 (GMT) |
commit | 802498fcd43558a10bb7477d3957cdd27fd8ec09 (patch) | |
tree | c40ddd859b032ffa7ed9c6df1173312c0bb1947d /src/corelib/tools/qbytearray.cpp | |
parent | 901fee7e610ec53f744416aeeca89c4605923120 (diff) | |
parent | 538e7b8ddf45936bb274ed3230b591b3459edfa7 (diff) | |
download | Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.zip Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.gz Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.bz2 |
Merge remote branch 'qt/master' into file-engine-refactor
Conflicts:
demos/declarative/minehunt/minehunt.pro
src/corelib/io/io.pri
src/corelib/io/qfsfileengine.cpp
src/corelib/io/qfsfileengine_unix.cpp
src/corelib/io/qfsfileengine_win.cpp
src/s60installs/bwins/QtCoreu.def
src/s60installs/bwins/QtDeclarativeu.def
src/s60installs/bwins/QtGuiu.def
src/s60installs/eabi/QtCoreu.def
src/s60installs/eabi/QtDeclarativeu.def
src/s60installs/eabi/QtGuiu.def
tests/auto/qapplication/test/test.pro
tests/auto/qaudioinput/qaudioinput.pro
tests/auto/qaudiooutput/qaudiooutput.pro
tests/auto/qchar/qchar.pro
tests/auto/qdiriterator/qdiriterator.pro
tests/auto/qsound/qsound.pro
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 21 |
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) /*! |