mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
Common/coreinit: fix Unix mmap failure detection and other robustness issues
- MemMapperUnix: mmap returns MAP_FAILED (not NULL) on failure; translate it to nullptr so the existing '!ptr' checks in the memory backend actually detect a failed reservation. - coreinit: bound writes to the fixed 256-entry active-thread array. - betype: operator|(betype) returned a reference to a local temporary; return by value like the sibling overload.
This commit is contained in:
parent
125355b7e1
commit
855e51f3f8
@ -154,8 +154,13 @@ namespace coreinit
|
||||
}
|
||||
if (alreadyActive == false)
|
||||
{
|
||||
activeThread[activeThreadCount] = threadMPTR;
|
||||
activeThreadCount++;
|
||||
if (activeThreadCount < 256)
|
||||
{
|
||||
activeThread[activeThreadCount] = threadMPTR;
|
||||
activeThreadCount++;
|
||||
}
|
||||
else
|
||||
cemuLog_log(LogType::Force, "coreinit: active thread list is full, cannot register thread");
|
||||
}
|
||||
|
||||
__OSCreateHostThread(thread);
|
||||
|
||||
@ -157,7 +157,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
betype<T>& operator|(const betype<T>& v) const requires (requires (T& x, const T& y) { x | y; })
|
||||
betype<T> operator|(const betype<T>& v) const requires (requires (T& x, const T& y) { x | y; })
|
||||
{
|
||||
betype<T> tmp(*this);
|
||||
tmp.m_value = tmp.m_value | v.m_value;
|
||||
|
||||
@ -32,7 +32,8 @@ namespace MemMapper
|
||||
|
||||
void* ReserveMemory(void* baseAddr, size_t size, PAGE_PERMISSION permissionFlags)
|
||||
{
|
||||
return mmap(baseAddr, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
void* r = mmap(baseAddr, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
return r == MAP_FAILED ? nullptr : r;
|
||||
}
|
||||
|
||||
void FreeReservation(void* baseAddr, size_t size)
|
||||
@ -55,7 +56,11 @@ namespace MemMapper
|
||||
r = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = mmap(baseAddr, size, GetProt(permissionFlags), MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (r == MAP_FAILED)
|
||||
r = nullptr;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user