AK: Calculate the chunk index correctly in DuplexMemoryStream.

This commit is contained in:
asynts 2020-09-11 14:36:12 +02:00 committed by Andreas Kling
parent dbd2fa8b8f
commit 049f709d0b
Notes: sideshowbarker 2024-07-19 02:46:34 +09:00

View File

@ -232,7 +232,7 @@ public:
{
size_t nread = 0;
while (bytes.size() - nread > 0 && m_write_offset - m_read_offset - nread > 0) {
const auto chunk_index = (m_read_offset - m_base_offset) / chunk_size;
const auto chunk_index = (m_read_offset - m_base_offset + nread) / chunk_size;
const auto chunk_bytes = m_chunks[chunk_index].bytes().slice(m_read_offset % chunk_size).trim(m_write_offset - m_read_offset - nread);
nread += chunk_bytes.copy_trimmed_to(bytes.slice(nread));
}