From a692c8a78d34334fa1974231971e9847cd71bec5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 26 Mar 2025 12:46:57 +0100 Subject: [PATCH] Fix qRound(inf) assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some extreme cases we can return a finite float, and then turn it infinite when multiplying it to calculate the index positions. Avoid the whole thing by clamping to a brightness of +-32768 times the white point standard, which is well within current HDR standards. Credit to OSS-Fuzz which detected the assert. Pick-to: 6.8 Change-Id: If007732a8d59ea27514f17674d318a099a057281 Reviewed-by: Eirik Aavitsland Reviewed-by: Robert Löhning (cherry picked from commit 2b7ecfab7d8cb149ffc02285906f95906f2f1343) Reviewed-by: Qt Cherry-pick Bot --- src/gui/painting/qcolortransferfunction_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qcolortransferfunction_p.h b/src/gui/painting/qcolortransferfunction_p.h index b9a09b4646a..3ae2fdd410d 100644 --- a/src/gui/painting/qcolortransferfunction_p.h +++ b/src/gui/painting/qcolortransferfunction_p.h @@ -56,7 +56,8 @@ public: if (x < m_d) return m_c * x + m_f; float t = std::pow(m_a * x + m_b, m_g); - if (std::isfinite(t)) + // Avoid NaN math, and leave room to multiply with 65280 and store in an int. + if (std::isfinite(t) && t > std::numeric_limits::min() && t < std::numeric_limits::max()) return t + m_e; if (t > 0.f) return 1.f;