summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2009-09-10 14:14:59 (GMT)
committerRobert Griebl <rgriebl@trolltech.com>2009-09-11 11:18:52 (GMT)
commite2411ebd04bf9a55e6e3b24cc7886e597521d473 (patch)
tree76344082302b32f21977bd0b57e2546c8abed2a8 /tests
parenta5a27973b1e4df62217ed510229b0d8dfa70e354 (diff)
downloadQt-e2411ebd04bf9a55e6e3b24cc7886e597521d473.zip
Qt-e2411ebd04bf9a55e6e3b24cc7886e597521d473.tar.gz
Qt-e2411ebd04bf9a55e6e3b24cc7886e597521d473.tar.bz2
Out of memory fix for qUncompress
qUncompress shouldn't crash when running out of memory, since it might deal with buffers which are not under user control (same behavior as Qt 4.5). It will however throw a std::bad_alloc exception if Qt is compiled with exception handling. Reviewed-by: Harald Fernengel Reviewed-by: Ralf Engels Reviewed-by: Lars Knoll
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 44cfe4a..b0bf3df 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -236,6 +236,7 @@ void tst_QByteArray::qUncompress_data()
void tst_QByteArray::qUncompress()
{
QFETCH(QByteArray, in);
+ QFETCH(QByteArray, out);
#if defined Q_OS_HPUX && !defined __ia64 && defined Q_CC_GNU
QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll);
@@ -245,9 +246,20 @@ void tst_QByteArray::qUncompress()
QSKIP("Corrupt data causes this test to lock up on QNX", SkipAll);
#endif
- QTEST(::qUncompress(in), "out");
+ QByteArray res;
+ QT_TRY {
+ res = ::qUncompress(in);
+ } QT_CATCH(const std::bad_alloc &) {
+ res = QByteArray();
+ }
+ QCOMPARE(res, out);
- QTEST(::qUncompress(in + "blah"), "out");
+ QT_TRY {
+ res = ::qUncompress(in + "blah");
+ } QT_CATCH(const std::bad_alloc &) {
+ res = QByteArray();
+ }
+ QCOMPARE(res, out);
}
#endif