diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-20 13:12:49 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-20 13:46:35 (GMT) |
commit | 29423dcc76970253fd5bca43d0abba4876b85b85 (patch) | |
tree | 38a46066108309294bd59f1a57dd9bd53237520d | |
parent | baf0f7a203281e3e1184cdfe327fb1dfa6df03ea (diff) | |
download | Qt-29423dcc76970253fd5bca43d0abba4876b85b85.zip Qt-29423dcc76970253fd5bca43d0abba4876b85b85.tar.gz Qt-29423dcc76970253fd5bca43d0abba4876b85b85.tar.bz2 |
Fix crashes in QByteArray
tst_QByteArray is was crashing on linux 64bit.
The memory was freed twice, once by qRealloc, and one by QScopePointer::reset
This patch will leak if qRealloc fails because of OutOfMemory.
But we do not care as it is a corner case.
Reviewed-by: Harald Fernengel
Reviewed-by: Robert Griebl
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index d2fbf5a..4049925 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -538,7 +538,7 @@ QByteArray qUncompress(const uchar* data, int nbytes) forever { ulong alloc = len; - d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc)))); + d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.take(), sizeof(QByteArray::Data) + alloc)))); if (!d) { // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS qWarning("qUncompress: could not allocate enough memory to uncompress data"); @@ -551,7 +551,7 @@ QByteArray qUncompress(const uchar* data, int nbytes) switch (res) { case Z_OK: if (len != alloc) { - d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len)))); + d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.take(), sizeof(QByteArray::Data) + len)))); if (!d) { // we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS qWarning("qUncompress: could not allocate enough memory to uncompress data"); |