VERY experimental Nintendo Switch 2 emulator
C++
Common: Correctly set ptr to null if mmap fails in memory_util
Lioncashcc9f352b669e
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cppindex 71ef159c36..5cc869aea1 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;+#endifPanicAlert("Failed to allocate executable memory");}#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)@@ -88,6 +88,9 @@ void* AllocateMemoryPages(size_t size)#elsevoid* 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,