AK: Don't slice off the first byte of a BitStream read

This commit is contained in:
Tim Schumacher 2023-11-11 12:54:46 +01:00 committed by Andreas Kling
parent 4280f4d2c7
commit de49413bdf

View file

@ -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);