summaryrefslogtreecommitdiffstats
path: root/tests/auto/qbytearray
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2009-09-10 16:14:59 +0200
committerRobert Griebl <rgriebl@trolltech.com>2009-09-11 13:18:52 +0200
commite2411ebd04bf9a55e6e3b24cc7886e597521d473 (patch)
tree76344082302b32f21977bd0b57e2546c8abed2a8 /tests/auto/qbytearray
parenta5a27973b1e4df62217ed510229b0d8dfa70e354 (diff)
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/auto/qbytearray')
-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 44cfe4a135..b0bf3df8f9 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