summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-08-18 02:38:28 +0200
committerbunnei <bunneidev@gmail.com>2014-08-18 02:38:28 +0200
commit68c81f28d947193d050cb04bbcfd42b6ef1307f3 (patch)
tree9f210bd0887a2fbc2ce33acd64e2a8c498c013c0
parentMerge pull request #49 from archshift/redundantloop (diff)
parentCommon: Correctly set ptr to null if mmap fails in memory_util (diff)
downloadyuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.tar
yuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.tar.gz
yuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.tar.bz2
yuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.tar.lz
yuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.tar.xz
yuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.tar.zst
yuzu-68c81f28d947193d050cb04bbcfd42b6ef1307f3.zip
-rw-r--r--src/common/memory_util.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index e1cd6e553..e01e63175 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -51,14 +51,14 @@ void* AllocateExecutableMemory(size_t size, bool low)
// printf("Mapped executable memory at %p (size %ld)\n", ptr,
// (unsigned long)size);
-#if defined(__FreeBSD__)
- if (ptr == MAP_FAILED)
+#ifdef _WIN32
+ if (ptr == nullptr)
{
- ptr = NULL;
#else
- if (ptr == NULL)
+ if (ptr == MAP_FAILED)
{
-#endif
+ ptr = nullptr;
+#endif
PanicAlert("Failed to allocate executable memory");
}
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
@@ -88,6 +88,9 @@ void* AllocateMemoryPages(size_t size)
#else
void* ptr = mmap(0, size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
+
+ if (ptr == MAP_FAILED)
+ ptr = nullptr;
#endif
// printf("Mapped memory at %p (size %ld)\n", ptr,