mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2025-02-17 20:31:57 -05:00
Added memory size sanity check.
This commit is contained in:
parent
623624b456
commit
eecb4be9e9
1 changed files with 2 additions and 0 deletions
|
@ -2122,6 +2122,7 @@ again:
|
|||
|
||||
const Memory* alloc(uint32_t _size)
|
||||
{
|
||||
BX_CHECK(0 < _size, "Invalid memory operation. _size is 0.");
|
||||
Memory* mem = (Memory*)BX_ALLOC(g_allocator, sizeof(Memory) + _size);
|
||||
mem->size = _size;
|
||||
mem->data = (uint8_t*)mem + sizeof(Memory);
|
||||
|
@ -2130,6 +2131,7 @@ again:
|
|||
|
||||
const Memory* copy(const void* _data, uint32_t _size)
|
||||
{
|
||||
BX_CHECK(0 < _size, "Invalid memory operation. _size is 0.");
|
||||
const Memory* mem = alloc(_size);
|
||||
memcpy(mem->data, _data, _size);
|
||||
return mem;
|
||||
|
|
Loading…
Reference in a new issue