mirror of https://github.com/qt/qtbase.git
Fix crash when creating distance field for large glyph
Do the multiplication of the normal components in floating point to avoid integer overflows. Also add an assert, since a scale of 0 here will cause a normal of (0, 0) which will assert further into the drawRectangle() function, and the cause is not immediately clear. Task-number: QTBUG-51956 Change-Id: If7187d56af28eaa149f8f362050a587da5adb262 Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
This commit is contained in:
parent
fe97ecf408
commit
c2d3c2b9f9
|
@ -544,7 +544,9 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
|
|||
QPoint n(to.y() - from.y(), from.x() - to.x());
|
||||
if (n.x() == 0 && n.y() == 0)
|
||||
continue;
|
||||
int scale = qRound((offs << 16) / qSqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16
|
||||
int scale = qRound((offs << 16) / qSqrt(qreal(n.x()) * n.x() + qreal(n.y()) * n.y())); // 8:16
|
||||
Q_ASSERT(scale != 0);
|
||||
|
||||
n.rx() = n.x() * scale >> 8;
|
||||
n.ry() = n.y() * scale >> 8;
|
||||
normals.append(n);
|
||||
|
|
Loading…
Reference in New Issue