From c2d3c2b9f97cd842f2cbcc28acbc7a140b45222f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 10 Jun 2016 13:38:31 +0200 Subject: 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 --- src/gui/text/qdistancefield.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index c493ca1dad..efe4cc9928 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -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); -- cgit v1.2.3