diff options
author | Robert Löhning <robert.loehning@qt.io> | 2021-01-29 12:05:12 +0100 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2021-01-29 13:44:28 +0000 |
commit | 9c5683f43346b30d3967496dfd0c8b12bd24f02c (patch) | |
tree | 612a6f5adff125a65da18790296c4a7340883067 /src/svg | |
parent | f22a95f05e67ebf24513bb2ec66e061441dd7511 (diff) | |
download | qtsvg-9c5683f43346b30d3967496dfd0c8b12bd24f02c.tar.gz |
Sanitize font weight value in QSvgFontStyle::apply
Assigning values outside the enum's range is undefined.
Fixes oss-fuzz issue 29432.
Pick-to: 6.0
Change-Id: I31f4d64a15803b13a3cb8dc07702da24ca74ebc2
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qsvgstyle.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index cf17944..e82d89c 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -263,7 +263,9 @@ void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states } else { states.fontWeight = m_weight; } - font.setWeight(QFont::Weight(states.fontWeight)); + font.setWeight(QFont::Weight(qBound(static_cast<int>(QFont::Weight::Thin), + states.fontWeight, + static_cast<int>(QFont::Weight::Black)))); } p->setFont(font); |