Skip to content

Commit

Permalink
Clamp parsed doubles to float representable values
Browse files Browse the repository at this point in the history
Parts of our rendering assumes incoming doubles can still be sane
floats.

Pick-to: 6.1 6.0 5.15 5.12
Fixes: QTBUG-91507
Change-Id: I7086a121e1b5ed47695a1251ea90e774dd8f148d
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
  • Loading branch information
Allan Sandfeld Jensen authored and rlohning committed Mar 4, 2021
1 parent f45a08a commit bfd6ee0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/svg/qsvghandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ static qreal toDouble(const QChar *&str)
val = -val;
} else {
val = QByteArray::fromRawData(temp, pos).toDouble();
if (qFpClassify(val) != FP_NORMAL)
// Do not tolerate values too wild to be represented normally by floats
if (qFpClassify(float(val)) != FP_NORMAL)
val = 0;
}
return val;
Expand Down Expand Up @@ -3036,6 +3037,8 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
ncy = toDouble(cy);
if (!r.isEmpty())
nr = toDouble(r);
if (nr < 0.5)
nr = 0.5;

qreal nfx = ncx;
if (!fx.isEmpty())
Expand Down

0 comments on commit bfd6ee0

Please sign in to comment.