mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
ZoneCodeGenerator: Fix throwing overflow exceptions too early due to wrong limit testing
This commit is contained in:
parent
ec9be6e1fd
commit
51862d8596
@ -113,7 +113,7 @@ void XBlockInputStream::LoadDataInBlock(void* dst, const size_t size)
|
|||||||
throw OutOfBlockBoundsException(block);
|
throw OutOfBlockBoundsException(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reinterpret_cast<uint8_t*>(dst) + size >= block->m_buffer + block->m_buffer_size)
|
if(reinterpret_cast<uint8_t*>(dst) + size > block->m_buffer + block->m_buffer_size)
|
||||||
{
|
{
|
||||||
throw BlockOverflowException(block);
|
throw BlockOverflowException(block);
|
||||||
}
|
}
|
||||||
@ -158,14 +158,14 @@ void XBlockInputStream::LoadNullTerminated(void* dst)
|
|||||||
size_t offset = reinterpret_cast<uint8_t*>(dst) - block->m_buffer;
|
size_t offset = reinterpret_cast<uint8_t*>(dst) - block->m_buffer;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
m_stream->Load(&byte, 1);
|
if (offset >= block->m_buffer_size)
|
||||||
block->m_buffer[offset++] = byte;
|
|
||||||
|
|
||||||
if(offset >= block->m_buffer_size)
|
|
||||||
{
|
{
|
||||||
throw BlockOverflowException(block);
|
throw BlockOverflowException(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_stream->Load(&byte, 1);
|
||||||
|
block->m_buffer[offset++] = byte;
|
||||||
|
|
||||||
} while(byte != 0);
|
} while(byte != 0);
|
||||||
|
|
||||||
m_block_offsets[block->m_index] = offset;
|
m_block_offsets[block->m_index] = offset;
|
||||||
@ -177,7 +177,7 @@ void** XBlockInputStream::InsertPointer()
|
|||||||
|
|
||||||
Align(sizeof(void*));
|
Align(sizeof(void*));
|
||||||
|
|
||||||
if(m_block_offsets[m_insert_block->m_index] + sizeof(void*) >= m_insert_block->m_buffer_size)
|
if(m_block_offsets[m_insert_block->m_index] + sizeof(void*) > m_insert_block->m_buffer_size)
|
||||||
{
|
{
|
||||||
throw BlockOverflowException(m_insert_block);
|
throw BlockOverflowException(m_insert_block);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user