mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 20:55:35 +03:00
AK: Fix reading across chunks in DuplexMemoryStream
This commit is contained in:
parent
cd8268e6fb
commit
3c41487db7
Notes:
sideshowbarker
2024-07-19 00:58:29 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/3c41487db76 Pull-request: https://github.com/SerenityOS/serenity/pull/4359 Issue: https://github.com/SerenityOS/serenity/issues/4345 Issue: https://github.com/SerenityOS/serenity/issues/4358
@ -252,7 +252,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 + 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);
|
||||
const auto chunk_bytes = m_chunks[chunk_index].bytes().slice((m_read_offset + nread) % chunk_size).trim(m_write_offset - m_read_offset - nread);
|
||||
nread += chunk_bytes.copy_trimmed_to(bytes.slice(nread));
|
||||
}
|
||||
|
||||
@ -279,8 +279,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
read(bytes);
|
||||
return true;
|
||||
return read(bytes) == bytes.size();
|
||||
}
|
||||
|
||||
size_t write(ReadonlyBytes bytes) override
|
||||
|
Loading…
Reference in New Issue
Block a user