mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-11 07:00:21 +02:00
Fixes 32-bit allocator returning 64-bit pointers on old kernels
In the case of a kernel older than 4.17 then MAP_FIXED_NOREPLACE doesn't exist. This adds a check in to see if the pointer returned was valid but not what we asked for
This commit is contained in:
1 parent
eaa3df9cba
commit
7cbe9579ba
1 file changed
+9
-1
@@ -207,7 +207,15 @@ restart:
|
||||
errno != EEXIST) {
|
||||
return reinterpret_cast<void*>(-errno);
|
||||
}
|
||||
else if (MappedPtr == MAP_FAILED) {
|
||||
else if (MappedPtr == MAP_FAILED ||
|
||||
MappedPtr >= reinterpret_cast<void*>(TOP_KEY << PAGE_SHIFT)) {
|
||||
// Handles the case where MAP_FIXED_NOREPLACE failed with MAP_FAILED
|
||||
// or if the host system's kernel isn't new enough then it returns the wrong pointer
|
||||
if (MappedPtr >= reinterpret_cast<void*>(TOP_KEY << PAGE_SHIFT)) {
|
||||
// Make sure to munmap this so we don't leak memory
|
||||
::munmap(MappedPtr, length);
|
||||
}
|
||||
|
||||
if (UpperPage == TOP_KEY) {
|
||||
BottomPage = BASE_KEY;
|
||||
Wrapped = true;
|
||||
|
||||
Reference in new issue
Block a user