diff options
author | Robert Löhning <robert.loehning@qt.io> | 2021-05-26 20:57:32 +0200 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2021-05-27 23:46:00 +0000 |
commit | aab3348c48f8ee7e05ef92e09e4eb3a59bd21d1a (patch) | |
tree | 7bd48cabc9e6b4120140346a344130c09f84e6d2 /src/gui/painting | |
parent | f677f62943164cb71a6960409b40f59a68fb9035 (diff) |
Avoid possible division by zero
"width / line.length()" didn't crash because it's a qreal but that's
still undefined behavior.
Fixes oss-fuzz issue 32984
Change-Id: Ia9c35b9eb5d86c4ce3c7f030b68e95ae83350c44
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 68ea3239f9..5b58c32c5f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1649,17 +1649,18 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) const QLineF *lines = reinterpret_cast<const QLineF *>(path.points()); for (int i = 0; i < lineCount; ++i) { - if (lines[i].p1() == lines[i].p2()) { + const QLineF line = s->matrix.map(lines[i]); + if (line.p1() == line.p2()) { if (s->lastPen.capStyle() != Qt::FlatCap) { QPointF p = lines[i].p1(); - QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()), + QLineF mappedline = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()), QPointF(p.x() + width*0.5, p.y()))); - d->rasterizer->rasterizeLine(line.p1(), line.p2(), width / line.length()); + d->rasterizer->rasterizeLine(mappedline.p1(), mappedline.p2(), + width / mappedline.length()); } continue; } - const QLineF line = s->matrix.map(lines[i]); if (qpen_style(s->lastPen) == Qt::SolidLine) { d->rasterizer->rasterizeLine(line.p1(), line.p2(), width / line.length(), |