Limit value in setFontSizeFromValue()

Avoids overflows in QFreetypeFace::computeSize and
QFontEngineBox::boundingBox

Fixes oss-fuzz issue 30290

Pick-to: 5.15 6.0 6.1
Change-Id: If8e9ff74bf706a701e26832ad21b3439a3b437f7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Robert Löhning 2021-02-26 22:37:32 +01:00
parent e14ccf0553
commit 976fede67c
1 changed files with 2 additions and 2 deletions

View File

@ -1143,14 +1143,14 @@ static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAd
s.chop(2);
value.variant = s;
if (value.variant.convert(QMetaType::fromType<qreal>())) {
font->setPointSizeF(value.variant.toReal());
font->setPointSizeF(qBound(qreal(0), value.variant.toReal(), qreal(1 << 24) - 1));
valid = true;
}
} else if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) {
s.chop(2);
value.variant = s;
if (value.variant.convert(QMetaType::fromType<int>())) {
font->setPixelSize(value.variant.toInt());
font->setPixelSize(qBound(0, value.variant.toInt(), (1 << 24) - 1));
valid = true;
}
}