Fixes CommandBuffer overflow check

This commit is contained in:
actboy168 2019-06-04 10:58:13 +08:00 committed by GitHub
parent 4748766009
commit ad559d6889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -815,7 +815,7 @@ namespace bgfx
void write(const void* _data, uint32_t _size)
{
BX_CHECK(m_size == BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE, "Called write outside start/finish?");
BX_CHECK(m_pos < m_size, "CommandBuffer::write error (pos: %d, size: %d).", m_pos, m_size);
BX_CHECK(m_pos + _size < m_size, "CommandBuffer::write error (pos: %d-%d, size: %d).", m_pos, m_pos + _size, m_size);
bx::memCopy(&m_buffer[m_pos], _data, _size);
m_pos += _size;
}
@ -829,7 +829,7 @@ namespace bgfx
void read(void* _data, uint32_t _size)
{
BX_CHECK(m_pos < m_size, "CommandBuffer::read error (pos: %d, size: %d).", m_pos, m_size);
BX_CHECK(m_pos + _size < m_size, "CommandBuffer::read error (pos: %d-%d, size: %d).", m_pos, m_pos + _size, m_size);
bx::memCopy(_data, &m_buffer[m_pos], _size);
m_pos += _size;
}
@ -843,7 +843,7 @@ namespace bgfx
const uint8_t* skip(uint32_t _size)
{
BX_CHECK(m_pos < m_size, "CommandBuffer::skip error (pos: %d, size: %d).", m_pos, m_size);
BX_CHECK(m_pos + _size < m_size, "CommandBuffer::skip error (pos: %d-%d, size: %d).", m_pos, m_pos + _size, m_size);
const uint8_t* result = &m_buffer[m_pos];
m_pos += _size;
return result;