diff --git a/Source/Core/Common/MemArenaAndroid.cpp b/Source/Core/Common/MemArenaAndroid.cpp index 3c4b800da8..bcba64e1e1 100644 --- a/Source/Core/Common/MemArenaAndroid.cpp +++ b/Source/Core/Common/MemArenaAndroid.cpp @@ -155,6 +155,9 @@ void* LazyMemoryRegion::Create(size_t size) { ASSERT(!m_memory); + if (size == 0) + return nullptr; + void* memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (memory == MAP_FAILED) { diff --git a/Source/Core/Common/MemArenaUnix.cpp b/Source/Core/Common/MemArenaUnix.cpp index ef359de908..9bf3633ee2 100644 --- a/Source/Core/Common/MemArenaUnix.cpp +++ b/Source/Core/Common/MemArenaUnix.cpp @@ -121,6 +121,9 @@ void* LazyMemoryRegion::Create(size_t size) { ASSERT(!m_memory); + if (size == 0) + return nullptr; + void* memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (memory == MAP_FAILED) { diff --git a/Source/Core/Common/MemArenaWin.cpp b/Source/Core/Common/MemArenaWin.cpp index ebf078f45b..b147ced53f 100644 --- a/Source/Core/Common/MemArenaWin.cpp +++ b/Source/Core/Common/MemArenaWin.cpp @@ -445,6 +445,9 @@ void* LazyMemoryRegion::Create(size_t size) { ASSERT(!m_memory); + if (size == 0) + return nullptr; + void* memory = VirtualAlloc(nullptr, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (!memory) {