Make sure the sqrt value in qdrawhelper is non-negative

It's possible for the "det" variable to exceed 0 and be negative.
This scenario is already handled in one case, this change will fix second case.

Fixes: QTBUG-120907
Change-Id: Ib30213b3455b5c6f3b8b8384e78e7b43158f93b5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit ba75e7770f7facf5f841e72ca0a4fd2a1a1fb6e1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Jacek Poplawski 2024-01-12 11:27:00 +01:00 committed by Qt Cherry-pick Bot
parent 2c53d990f7
commit 3340b82ee9

View File

@ -3255,6 +3255,7 @@ public:
static Type null() { return 0; }
static Type fetchSingle(const QGradientData& gradient, qreal v)
{
Q_ASSERT(std::isfinite(v));
return qt_gradient_pixel(&gradient, v);
}
static Type fetchSingle(const QGradientData& gradient, int v)
@ -3275,6 +3276,7 @@ public:
static Type null() { return QRgba64::fromRgba64(0); }
static Type fetchSingle(const QGradientData& gradient, qreal v)
{
Q_ASSERT(std::isfinite(v));
return qt_gradient_pixel64(&gradient, v);
}
static Type fetchSingle(const QGradientData& gradient, int v)
@ -3296,6 +3298,7 @@ public:
static Type null() { return QRgbaFloat32::fromRgba64(0,0,0,0); }
static Type fetchSingle(const QGradientData& gradient, qreal v)
{
Q_ASSERT(std::isfinite(v));
return qt_gradient_pixelFP(&gradient, v);
}
static Type fetchSingle(const QGradientData& gradient, int v)
@ -3445,7 +3448,13 @@ public:
}
} else {
while (buffer < end) {
*buffer++ = GradientBase::fetchSingle(data->gradient, qSqrt(det) - b);
BlendType result = GradientBase::null();
if (det >= 0) {
qreal w = qSqrt(det) - b;
result = GradientBase::fetchSingle(data->gradient, w);
}
*buffer++ = result;
det += delta_det;
delta_det += delta_delta_det;