Skip to content

Commit

Permalink
Windows: Fix crash dependent on alloc order.
Browse files Browse the repository at this point in the history
Without IR, we don't allocate executable memory, so the first allocation
always fails.
  • Loading branch information
unknownbrackets committed Mar 16, 2023
1 parent de4eb64 commit fa1a4d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Common/MemoryUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ void *AllocateExecutableMemory(size_t size) {
}

void *AllocateMemoryPages(size_t size, uint32_t memProtFlags) {
size = ppsspp_round_page(size);
#ifdef _WIN32
if (sys_info.dwPageSize == 0)
GetSystemInfo(&sys_info);
uint32_t protect = ConvertProtFlagsWin32(memProtFlags);
// Make sure to do this after GetSystemInfo().
size = ppsspp_round_page(size);
#if PPSSPP_PLATFORM(UWP)
void* ptr = VirtualAllocFromApp(0, size, MEM_COMMIT, protect);
#else
Expand All @@ -221,6 +222,7 @@ void *AllocateMemoryPages(size_t size, uint32_t memProtFlags) {
return nullptr;
}
#else
size = ppsspp_round_page(size);
uint32_t protect = ConvertProtFlagsUnix(memProtFlags);
void *ptr = mmap(0, size, protect, MAP_ANON | MAP_PRIVATE, -1, 0);
if (ptr == MAP_FAILED) {
Expand Down

0 comments on commit fa1a4d2

Please sign in to comment.