mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-12-06 07:12:28 +01:00
vm_native.cpp: Fix possible weakness of map_self()
This commit is contained in:
parent
e449227235
commit
09f71a8ecb
|
|
@ -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…
Reference in a new issue