Case 1
Since
fixed_codes[i].length is unt8_t
and
ll_histogram[i] is unt32_t
There is could be possible integer overflow at:
|
fixed_compressed_len += fixed_ll_codes[i].length * ll_histogram[i]; |
Possible fix:
static_cast<uint64_t>(ll_codes[i].length) * ll_histogram[i];
Case 2
Since
buffer_used(bit_buffer) + bit_buffer->m_bit_count - are unit32_t
at
|
compressed_len += 8 * buffer_used(bit_buffer) + bit_buffer->m_bit_count; |
it would be better to cast one of them to uint64_t because compressed_len is uint64_t