1
0
Fork 0
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:
asynts 2020-12-09 15:11:09 +01:00 committed by Andreas Kling
parent ce15c9a04c
commit 5b104eedaf
Notes: sideshowbarker 2024-07-19 00:56:35 +09:00
2 changed files with 21 additions and 1 deletions

View file

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