Limit value in setFontWeightFromValue()

QFont::setWeight() just accepts values between 0 and 900 anyway.

Fixes: oss-fuzz-24986
Change-Id: Ic65139a7821be3a12c65444d010736f03c8b74f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit ccc205bf38ffbe60180a069939a4aff01e7734e5)
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Robert Loehning 2020-10-09 11:57:10 +02:00
parent c4748f909c
commit a4fa3cce0b

View File

@ -1153,7 +1153,7 @@ static bool setFontWeightFromValue(const QCss::Value &value, QFont *font)
}
if (value.type != Value::Number)
return false;
font->setWeight(qMin(value.variant.toInt() / 8, 99));
font->setWeight(qRound(qBound(0.0, value.variant.toDouble() / 8.0, 99.0)));
return true;
}