mirror of https://github.com/madler/zlib.git
The condition `state->bits + (uInt)bits > 32` was replaced with `state->bits + (uInt)bits >= 32` to prevent potential overflow when shifting `value` by `state->bits`. A shift equal to or greater than the size of the data type (32 bits) can lead to undefined behavior. This change ensures that the sum of `state->bits` and `bits` never reaches 32, avoiding the risk of overflow in the expression `(unsigned)value << state->bits`. While the scenario leading to overflow is unlikely in practice due to the constraints of the calling function `inflatePrime`, I recommend applying this change to improve code robustness and adhere to safe coding practices. This is a preventive measure to eliminate any potential risks in edge cases. Triggers found by static analyzer Svace. Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>pull/1051/head
parent
5a82f71ed1
commit
55eca15035
1 changed files with 1 additions and 1 deletions
Loading…
Reference in new issue