summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2020-08-03 22:42:23 +0200
committerRobert Loehning <robert.loehning@qt.io>2020-08-25 17:59:10 +0200
commitc0d0949448c5a75d50ca189974d4d9f48133aea8 (patch)
tree4754cd61f7f61289c2171a93e6716b7165bef9f2 /tests
parente1d7df5ce9eb1d370e1b6dcd31ced4029082d63d (diff)
QLineF: Don't try calculating a unit vector when length is null
It's undefined and causes a division by zero. Fixes: oss-fuzz-24561 Pick-to: 5.12 5.15 Change-Id: Idebaba4b286e3ab0ecb74825d203244958ce6aec Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qline/tst_qline.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp
index 4f3be0f3d9..7e07e9d1e2 100644
--- a/tests/auto/corelib/tools/qline/tst_qline.cpp
+++ b/tests/auto/corelib/tools/qline/tst_qline.cpp
@@ -40,6 +40,8 @@ private slots:
void testLength();
void testLength_data();
+ void testSetLength();
+
void testCenter();
void testCenter_data();
@@ -258,6 +260,15 @@ void tst_QLine::testLength()
QCOMPARE(l.dy(), qreal(vy));
}
+void tst_QLine::testSetLength()
+{
+ QLineF l(0, 0, 4e-323, 5e-324);
+ const qreal newLength = 1892;
+ const qreal oldLength = l.length();
+ l.setLength(newLength);
+ QCOMPARE(l.length(), oldLength ? newLength : 0);
+}
+
void tst_QLine::testCenter()
{
QFETCH(int, x1);