diff --git a/src/util/BitStream.cpp b/src/util/BitStream.cpp index 9163b63..61f9b5c 100644 --- a/src/util/BitStream.cpp +++ b/src/util/BitStream.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace ki { @@ -148,7 +149,7 @@ namespace ki void BitStream::expand_buffer() { // Work out a new buffer size - auto new_size = (m_buffer_size << 1) + 2; + auto new_size = (2 << (uint64_t)log2(m_position.get_byte())) + 2; if (new_size < m_buffer_size) new_size = std::numeric_limits::max();