diff options
| author | Dan Engelbrecht <[email protected]> | 2024-01-22 10:33:15 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-22 10:33:15 +0100 |
| commit | 884e51fea604dcdba95d13dfdd9f4ad108d0521a (patch) | |
| tree | 18362159d6b38ffe5f8988dc18f7e5703cd30d0a | |
| parent | Use correct HTTP range values. (#632) (diff) | |
| download | zen-884e51fea604dcdba95d13dfdd9f4ad108d0521a.tar.xz zen-884e51fea604dcdba95d13dfdd9f4ad108d0521a.zip | |
make sure to advance read buffer pointer in BasicFileWriter::Write (#633)
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenutil/basicfile.cpp | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e8d9df2c..bab4ef63a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Improvement: Separated cache RPC handling code from general structured cache HTTP code - Bugfix: RPC recording would not release memory as early as intended which resulted in memory buildup during long recording sessions. Previously certain memory was only released when recording stopped, now it gets released immediately when a segment is complete and written to disk. - Bugfix: File log format now contains dates again (PR #631) +- Bugfix: Make sure to write the correct data in BasicFileWriter when writing items that are not a multiple of the buffer size ## 0.2.38 - Bugfix: Cache RPC recording would drop data when it reached 4GB of inline chunk data in a segment diff --git a/src/zenutil/basicfile.cpp b/src/zenutil/basicfile.cpp index 819d0805d..dbae76717 100644 --- a/src/zenutil/basicfile.cpp +++ b/src/zenutil/basicfile.cpp @@ -712,6 +712,7 @@ BasicFileWriter::Write(void* Data, uint64_t Size, uint64_t FileOffset) m_BufferStart = m_BufferEnd = FileOffset; } + const uint8_t* DataPtr = (const uint8_t*)Data; while (Size) { const uint64_t RemainingBufferCapacity = m_BufferStart + m_BufferSize - m_BufferEnd; @@ -721,11 +722,12 @@ BasicFileWriter::Write(void* Data, uint64_t Size, uint64_t FileOffset) ZEN_ASSERT_SLOW(BufferWriteOffset < m_BufferSize); ZEN_ASSERT_SLOW((BufferWriteOffset + BlockWriteBytes) <= m_BufferSize); - memcpy(m_Buffer + BufferWriteOffset, Data, BlockWriteBytes); + memcpy(m_Buffer + BufferWriteOffset, DataPtr, BlockWriteBytes); Size -= BlockWriteBytes; m_BufferEnd += BlockWriteBytes; FileOffset += BlockWriteBytes; + DataPtr += BlockWriteBytes; if ((m_BufferEnd - m_BufferStart) == m_BufferSize) { |