mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 13:01:27 +12:00
vm_native.cpp: Fix possible weakness of map_self()
This commit is contained in:
parent
1f81d42416
commit
79b63556bb
1 changed files with 12 additions and 8 deletions
|
@ -969,20 +969,24 @@ namespace utils
|
|||
{
|
||||
void* ptr = m_ptr;
|
||||
|
||||
while (!ptr)
|
||||
for (void* mapped = nullptr; !ptr;)
|
||||
{
|
||||
const auto mapped = this->map(nullptr, prot);
|
||||
if (!mapped)
|
||||
{
|
||||
mapped = this->map(nullptr, prot);
|
||||
}
|
||||
|
||||
// Install mapped memory
|
||||
if (!m_ptr.compare_exchange(ptr, mapped))
|
||||
{
|
||||
// Mapped already, nothing to do.
|
||||
this->unmap(mapped);
|
||||
}
|
||||
else
|
||||
if (m_ptr.compare_exchange(ptr, mapped))
|
||||
{
|
||||
ptr = mapped;
|
||||
}
|
||||
else if (ptr)
|
||||
{
|
||||
// Mapped already, nothing to do.
|
||||
ensure(ptr != mapped);
|
||||
this->unmap(mapped);
|
||||
}
|
||||
}
|
||||
|
||||
return static_cast<u8*>(ptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue