From 33450c80c3ca39ef1875f9c72898ba5749d06142 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 31 Jul 2014 00:47:44 -0500 Subject: [PATCH] Fixes a check for what mmap returns. On error mmap returns MAP_FAILED(-1) not null. FreeBSD was checking the return correctly, Linux was not. This was noticed by triad attempting to run Dolphin under valgrind and not getting a memory space under the 2GB limit(Because -1 wraps around on unsigned obviously) --- Source/Core/Common/MemoryUtil.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Common/MemoryUtil.cpp b/Source/Core/Common/MemoryUtil.cpp index 0ae08ced89..3a10d031cf 100644 --- a/Source/Core/Common/MemoryUtil.cpp +++ b/Source/Core/Common/MemoryUtil.cpp @@ -54,13 +54,13 @@ void* AllocateExecutableMemory(size_t size, bool low) // printf("Mapped executable memory at %p (size %ld)\n", ptr, // (unsigned long)size); -#if defined(__FreeBSD__) +#ifdef _WIN32 + if (ptr == nullptr) + { +#else if (ptr == MAP_FAILED) { ptr = nullptr; -#else - if (ptr == nullptr) - { #endif PanicAlert("Failed to allocate executable memory"); }