mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK: Fix offset calculation error in DuplexMemoryStream::write.
This commit is contained in:
parent
ce15c9a04c
commit
5b104eedaf
Notes:
sideshowbarker
2024-07-19 00:56:35 +09:00
Author: https://github.com/asynts
Commit: 5b104eedaf
Pull-request: https://github.com/SerenityOS/serenity/pull/4371
2 changed files with 21 additions and 1 deletions
|
@ -284,12 +284,14 @@ public:
|
|||
|
||||
size_t write(ReadonlyBytes bytes) override
|
||||
{
|
||||
// FIXME: This doesn't write around chunk borders correctly?
|
||||
|
||||
size_t nwritten = 0;
|
||||
while (bytes.size() - nwritten > 0) {
|
||||
if ((m_write_offset + nwritten) % chunk_size == 0)
|
||||
m_chunks.append(ByteBuffer::create_uninitialized(chunk_size));
|
||||
|
||||
nwritten += bytes.slice(nwritten).copy_trimmed_to(m_chunks.last().bytes().slice(m_write_offset % chunk_size));
|
||||
nwritten += bytes.slice(nwritten).copy_trimmed_to(m_chunks.last().bytes().slice((m_write_offset + nwritten) % chunk_size));
|
||||
}
|
||||
|
||||
m_write_offset += nwritten;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue