diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2019-03-01 02:44:37 -0800 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2019-03-01 11:44:37 +0100 |
commit | 5deeb8367fbe260fb44e403a56b1c6eee94857af (patch) | |
tree | 29e31638ff1cdf6972022e5723d746502751f35c /inffast.c | |
parent | 9dadce4e7ad846c5e837949d467109412ac138ac (diff) |
Fixed arithmetic overflow warnings on Windows (#302)
Fixed arithmetic overflow warnings in MSVC.
Fixed uint64_t to uint32_t casting warning.
Added assert to check if bits is greater than 32 before cast.
Diffstat (limited to 'inffast.c')
-rw-r--r-- | inffast.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -12,7 +12,7 @@ /* Return the low n bits of the bit accumulator (n < 16) */ #define BITS(n) \ - (hold & ((1U << (n)) - 1)) + (hold & ((UINT64_C(1) << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ @@ -447,7 +447,7 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { len = bits >> 3; in -= len; bits -= len << 3; - hold &= (1U << bits) - 1; + hold &= (UINT64_C(1) << bits) - 1; /* update state and return */ strm->next_in = in; @@ -458,7 +458,9 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { strm->avail_out = (unsigned)(out < end ? (INFLATE_FAST_MIN_LEFT - 1) + (end - out) : (INFLATE_FAST_MIN_LEFT - 1) - (out - end)); - state->hold = hold; + + Assert(bits <= 32, "Remaining bits greater than 32"); + state->hold = (uint32_t)hold; state->bits = bits; return; } |