QProgressBar: prevent integer overflow

If `value` is INT_MAX and `lastPaintedValue` is -1 (the default), the
subtraction will overflow. Extend the arguments to 64 bits. The result
is only used for a double comparison anyhow.

Change-Id: Id4a5396c61da81932ac626b3102e583a74264df4
Pick-to: 6.9 6.8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2025-01-28 03:14:48 +01:00
parent 45e90b73c7
commit 8e843ddba8

View File

@ -111,7 +111,7 @@ bool QProgressBarPrivate::repaintRequired() const
if (value == lastPaintedValue)
return false;
const int valueDifference = qAbs(value - lastPaintedValue);
const qint64 valueDifference = qAbs(qint64(value) - qint64(lastPaintedValue));
if (value == minimum || value == maximum)
return true;