Fix an unsigned integer overflow error in enc/cost.h
Change-Id: I9774b59c417c185f09a61a115364b9642976a100
(cherry picked from commit 0b2c58a91c
)
This commit is contained in:
parent
13cf1d2e41
commit
7416280d75
@ -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…
Reference in New Issue
Block a user