Arithmetic overflow: Using operator '<<' on a 4 byte value and then casting the result to a 8 byte value.
Cast the value to the wider type before calling operator '<<' to avoid overflow (io.2).
Arithmetic overflow: 32-bit value is shifted, then cast to 64-bit value.
Results might not be an expected value.
/* ========================================================================= */
int ZEXPORT PREFIX(deflatePrime)(PREFIX3(stream) *strm, int bits, int value) {
deflate_state *s;
- int put;
+ int32_t put;
if (deflateStateCheck(strm))
return Z_STREAM_ERROR;
put = BIT_BUF_SIZE - s->bi_valid;
if (put > bits)
put = bits;
- s->bi_buf |= (uint64_t)((value & ((1 << put) - 1)) << s->bi_valid);
+ s->bi_buf |= (((uint64_t)value & ((UINT64_C(1) << put) - 1)) << s->bi_valid);
s->bi_valid += put;
zng_tr_flush_bits(s);
value >>= put;