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>
This commit is contained in:
parent
f677f62943
commit
aab3348c48
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user