summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-06-29 10:02:33 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-06-29 10:02:33 (GMT)
commit1f57ef786ae5b19cfc4d52425e05413a4f952586 (patch)
tree04e3276e91f48d4f038fd01eb7bebe2bc6436712 /src/corelib
parentc1e73ebf3b2f15646ba6b755a37b12e65881e9ae (diff)
downloadQt-1f57ef786ae5b19cfc4d52425e05413a4f952586.zip
Qt-1f57ef786ae5b19cfc4d52425e05413a4f952586.tar.gz
Qt-1f57ef786ae5b19cfc4d52425e05413a4f952586.tar.bz2
Added try-catch block around resize in QByteArray's qUncompress,
as corrupted data can cause alloc failure in low-mem environments. Reviewed-by: axis
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qbytearray.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index ae6561f..d282387 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -538,9 +538,13 @@ QByteArray qUncompress(const uchar* data, int nbytes)
QByteArray baunzip;
int res;
do {
- baunzip.resize(len);
- res = ::uncompress((uchar*)baunzip.data(), &len,
- (uchar*)data+4, nbytes-4);
+ QT_TRY {
+ baunzip.resize(len);
+ res = ::uncompress((uchar*)baunzip.data(), &len,
+ (uchar*)data+4, nbytes-4);
+ } QT_CATCH (const std::bad_alloc &) {
+ res = Z_MEM_ERROR;
+ }
switch (res) {
case Z_OK: