From eecb4be9e99198a49a7d7fd26354b33d9744d507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 28 Jul 2015 21:39:26 -0700 Subject: [PATCH] Added memory size sanity check. --- src/bgfx.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 2d71223f7..90d441320 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -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;