From 1f57ef786ae5b19cfc4d52425e05413a4f952586 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 29 Jun 2009 13:02:33 +0300 Subject: Added try-catch block around resize in QByteArray's qUncompress, as corrupted data can cause alloc failure in low-mem environments. Reviewed-by: axis --- src/corelib/tools/qbytearray.cpp | 10 +++++++--- 1 file 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: -- cgit v0.12