Fix calculating wrong chunk buffer window when only the block header is inside a chunk and all the data is in the next

This commit is contained in:
Jan 2023-10-15 22:31:50 +02:00
parent 75cd9bd4e4
commit 4811d41ec8

View File

@ -176,6 +176,11 @@ public:
void StartNewBlock()
{
AlignToBlockHeader();
// Skip to the next chunk when only the header could fit into the current chunk anyway
if (static_cast<size_t>(utils::Align(m_current_offset, static_cast<int64_t>(ipak_consts::IPAK_CHUNK_SIZE)) - m_current_offset) <= sizeof(IPakDataBlockHeader))
FlushChunk();
m_current_block_header_offset = m_current_offset;
m_current_block = {};
m_current_block.countAndOffset.offset = static_cast<uint32_t>(m_file_offset);