From ccc205bf38ffbe60180a069939a4aff01e7734e5 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 9 Oct 2020 11:57:10 +0200 Subject: Limit value in setFontWeightFromValue() QFont::setWeight() just accepts values between 0 and 900 anyway. Fixes: oss-fuzz-24986 Pick-to: 5.12 5.15 Change-Id: Ic65139a7821be3a12c65444d010736f03c8b74f5 Reviewed-by: Edward Welbourne --- src/gui/text/qcssparser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 3b2f8aaef0..4dc6767cf4 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1195,7 +1195,8 @@ static bool setFontWeightFromValue(const QCss::Value &value, QFont *font) } if (value.type != Value::Number) return false; - font->setWeight(QFont::Weight(value.variant.toInt())); + // .toInt() would call qRound64() and might overflow the long long there + font->setWeight(QFont::Weight(qRound(qBound(0.0, value.variant.toDouble(), 1001.0)))); return true; } -- cgit v1.2.3