[Base] BitStream: Prevent readout beyond buffer

This commit is contained in:
Gliniak 2022-10-17 11:50:09 +02:00
parent 45050b2380
commit e7b76d32b4
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@ uint64_t BitStream::Peek(size_t num_bits) {
assert_false(num_bits > 57);
assert_false(offset_bits_ + num_bits > size_bits_);
size_t offset_bytes = offset_bits_ >> 3;
size_t offset_bytes = std::min(offset_bits_ >> 3, (size_bits_ - 64) >> 3);
size_t rel_offset_bits = offset_bits_ - (offset_bytes << 3);
// offset -->