From 0236e3ab94508b700a11ab83fab7bbd39ee651bf Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 15 Jan 2018 18:03:36 -0800 Subject: [PATCH] QStyleSheetsStyle: Avoid possible division by zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5a7588c07106227e2a8b5e1f180230ef5b0342d1 Task-number: QTBUG-65228 Reviewed-by: Friedemann Kleint Reviewed-by: Alexandru Croitor Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qstylesheetstyle.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 8ff8ab65a6..f70313d49e 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3971,10 +3971,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q x += reverse ? -chunkWidth : chunkWidth; --chunkCount; }; - } else { + } else if (chunkWidth > 0) { + const int chunkCount = ceil(qreal(fillWidth)/chunkWidth); int x = reverse ? r.left() + r.width() - chunkWidth : r.x(); - for (int i = 0; i < ceil(qreal(fillWidth)/chunkWidth); ++i) { + for (int i = 0; i < chunkCount; ++i) { r.setRect(x, rect.y(), chunkWidth, rect.height()); r = m.mapRect(QRectF(r)).toRect(); subRule.drawRule(p, r);