diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-10-26 12:58:03 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-10-26 13:19:41 (GMT) |
commit | 96b18246c4930332cadc80f97202e44110e22a4d (patch) | |
tree | e88f1fa479fa77de5eac30a68d6121e2e9ade4b6 /tests/auto/qpixmap/tst_qpixmap.cpp | |
parent | e2ef97128c006ac2a5c99c67bb54eebaa3b45720 (diff) | |
download | Qt-96b18246c4930332cadc80f97202e44110e22a4d.zip Qt-96b18246c4930332cadc80f97202e44110e22a4d.tar.gz Qt-96b18246c4930332cadc80f97202e44110e22a4d.tar.bz2 |
QPixmap::loadFromData: Do not crash on empty/invalid data/length
Task-number: 262636
Reviewed-by: gunnar
Diffstat (limited to 'tests/auto/qpixmap/tst_qpixmap.cpp')
-rw-r--r-- | tests/auto/qpixmap/tst_qpixmap.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 9f5aee2..53b6230 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -166,6 +166,7 @@ private slots: void fromImage_crash(); void fromData(); + void loadFromDataNullValues(); void preserveDepth(); }; @@ -1436,6 +1437,26 @@ void tst_QPixmap::fromData() QCOMPARE(img.pixel(0, 1), QRgb(0xff000000)); } +void tst_QPixmap::loadFromDataNullValues() +{ + { + QPixmap pixmap; + pixmap.loadFromData(QByteArray()); + QVERIFY(pixmap.isNull()); + } + { + QPixmap pixmap; + pixmap.loadFromData(0, 123); + QVERIFY(pixmap.isNull()); + } + { + QPixmap pixmap; + const uchar bla[] = "bla"; + pixmap.loadFromData(bla, 0); + QVERIFY(pixmap.isNull()); + } +} + void tst_QPixmap::task_246446() { // This crashed without the bugfix in 246446 |