From de49413bdfa4ff6e21dcb830d1ef8bb8b7afb8f8 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 11 Nov 2023 12:54:46 +0100 Subject: [PATCH] AK: Don't slice off the first byte of a BitStream read --- AK/BitStream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AK/BitStream.h b/AK/BitStream.h index e7e83ff4ea..0da3aae26d 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -29,8 +29,8 @@ public: { if (m_current_byte.has_value() && is_aligned_to_byte_boundary()) { bytes[0] = m_current_byte.release_value(); - // FIXME: This accidentally slices off the first byte of the returned span. - return m_stream->read_some(bytes.slice(1)); + auto freshly_read_bytes = TRY(m_stream->read_some(bytes.slice(1))); + return bytes.trim(1 + freshly_read_bytes.size()); } align_to_byte_boundary(); return m_stream->read_some(bytes);