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
e449227235
commit
09f71a8ecb
1 changed files with 12 additions and 8 deletions
|
@ -969,20 +969,24 @@ namespace utils
|
||||||
{
|
{
|
||||||
void* ptr = m_ptr;
|
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
|
// Install mapped memory
|
||||||
if (!m_ptr.compare_exchange(ptr, mapped))
|
if (m_ptr.compare_exchange(ptr, mapped))
|
||||||
{
|
|
||||||
// Mapped already, nothing to do.
|
|
||||||
this->unmap(mapped);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ptr = mapped;
|
ptr = mapped;
|
||||||
}
|
}
|
||||||
|
else if (ptr)
|
||||||
|
{
|
||||||
|
// Mapped already, nothing to do.
|
||||||
|
ensure(ptr != mapped);
|
||||||
|
this->unmap(mapped);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<u8*>(ptr);
|
return static_cast<u8*>(ptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue