summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2020-10-09 11:57:10 +0200
committerRobert Loehning <robert.loehning@qt.io>2020-11-09 13:03:52 +0000
commitccc205bf38ffbe60180a069939a4aff01e7734e5 (patch)
treef3190d9618d5309ab7b4256d252c6e250d504734 /src
parentec1d553bbfb9879a5cedfbe030bb01f1c4d97dca (diff)
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 <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qcssparser.cpp3
1 files changed, 2 insertions, 1 deletions
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;
}