From a26b91291ca4bcdb1a4357863683b4af3a6205c8 Mon Sep 17 00:00:00 2001 From: Master Builder Date: Thu, 19 May 2022 14:01:56 +0000 Subject: [PATCH] Common/Linux/LnxHostSys: Fixed compatibility issues with FreeBSD, made error handling more explicit --- common/Linux/LnxHostSys.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/Linux/LnxHostSys.cpp b/common/Linux/LnxHostSys.cpp index ab14143b5e..f83f238f09 100644 --- a/common/Linux/LnxHostSys.cpp +++ b/common/Linux/LnxHostSys.cpp @@ -144,7 +144,12 @@ void* HostSys::MmapReservePtr(void* base, size_t size) // or anonymous source, with PROT_NONE (no-access) permission. Since the mapping // is completely inaccessible, the OS will simply reserve it and will not put it // against the commit table. - return mmap(base, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + void* result = mmap(base, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + + if (result == MAP_FAILED) + result = nullptr; + + return result; } bool HostSys::MmapCommitPtr(void* base, size_t size, const PageProtectionMode& mode)