diff options
author | Robert Loehning <robert.loehning@qt.io> | 2020-08-03 15:15:30 +0200 |
---|---|---|
committer | Robert Loehning <robert.loehning@qt.io> | 2020-08-07 16:21:16 +0000 |
commit | 7fa5fdae5c4f4c83acb74ff8cd65eacfa567a727 (patch) | |
tree | 25c79ae0f0ca8417820adbcf8ac45eb82af38290 /src/gui/painting/qbezier.cpp | |
parent | 315257eabea010bf697415cdc0f6ec1e29b74d2b (diff) |
QBezier: Don't try calculating a unit vector when length is null
It's undefined and causes a division by zero.
Fixes: oss-fuzz-24273
Pick-to: 5.12 5.15
Change-Id: I3d34d5c43cccff9255abaf87af265ddea3fe6d95
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qbezier.cpp')
-rw-r--r-- | src/gui/painting/qbezier.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index d28fc2d120..8b1097ac5b 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -236,6 +236,8 @@ static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offse return Ok; } +QT_WARNING_DISABLE_FLOAT_COMPARE + static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold) { int map[4]; @@ -283,6 +285,8 @@ static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qr QPointF points_shifted[4]; QLineF prev = QLineF(QPointF(), points[1] - points[0]); + if (!prev.length()) + return Discard; QPointF prev_normal = prev.normalVector().unitVector().p2(); points_shifted[0] = points[0] + offset * prev_normal; |