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>
This commit is contained in:
Robert Loehning 2020-08-03 15:15:30 +02:00
parent 315257eabe
commit 7fa5fdae5c

View File

@ -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;