From d16508a285a5423ae9a5034e969801bce74ffb98 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 12 May 2014 09:09:24 +0200 Subject: Fix crash when loading invalid font data in QRawFont When passing invalid data to QRawFont, we need to fail gracefully and mark the font as invalid, instead of crashing. This crashed because of different missing sanity checks in the Windows and FontConfig font databases. [ChangeLog][Text] Fixed crash when trying to load a font from invalid data. Task-number: QTBUG-37190 Change-Id: I62c81217ec7d873350b575c9d4ae8e6f0a939540 Reviewed-by: Michael Bruning Reviewed-by: Konstantin Ritt --- tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index ae6e450301..20bfaf99dd 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -99,6 +99,8 @@ private slots: void rawFontSetPixelSize(); void multipleRawFontsFromData(); + + void rawFontFromInvalidData(); private: QString testFont; QString testFontBoldItalic; @@ -939,6 +941,15 @@ void tst_QRawFont::multipleRawFontsFromData() || testFont.style() != (testFontBoldItalic.style())); } +void tst_QRawFont::rawFontFromInvalidData() +{ + QByteArray invalidData("foobar"); + QRawFont font; + font.loadFromData(invalidData, 10, QFont::PreferDefaultHinting); + + QVERIFY(!font.isValid()); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QRawFont) -- cgit v1.2.3