mirror of
https://github.com/webmproject/libwebp.git
synced 2025-01-28 23:52:56 +01:00
Fix an unsigned integer overflow error in enc/cost.h
Change-Id: I9774b59c417c185f09a61a115364b9642976a100
This commit is contained in:
parent
386e4ba2f0
commit
0b2c58a91c
@ -44,7 +44,9 @@ int VP8RecordCoeffs(int ctx, const VP8Residual* const res);
|
||||
// Record proba context used.
|
||||
static WEBP_INLINE int VP8RecordStats(int bit, proba_t* const stats) {
|
||||
proba_t p = *stats;
|
||||
if (p >= 0xffff0000u) { // an overflow is inbound.
|
||||
// An overflow is inbound. Note we handle this at 0xfffe0000u instead of
|
||||
// 0xffff0000u to make sure p + 1u does not overflow.
|
||||
if (p >= 0xfffe0000u) {
|
||||
p = ((p + 1u) >> 1) & 0x7fff7fffu; // -> divide the stats by 2.
|
||||
}
|
||||
// record bit count (lower 16 bits) and increment total count (upper 16 bits).
|
||||
|
Loading…
x
Reference in New Issue
Block a user