mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-12-27 06:16:37 +01:00
Fix virtual memory allocation being out of range (#2464)
This commit is contained in:
parent
0d841c8d51
commit
b5190f1681
1 changed files with 7 additions and 4 deletions
|
@ -2411,9 +2411,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
{
|
{
|
||||||
if (info.State == MemoryState.Unmapped)
|
if (info.State == MemoryState.Unmapped)
|
||||||
{
|
{
|
||||||
ulong currBaseAddr = info.Address + reservedSize;
|
ulong currBaseAddr = info.Address <= regionStart ? regionStart : info.Address;
|
||||||
ulong currEndAddr = info.Address + info.Size - 1;
|
ulong currEndAddr = info.Address + info.Size - 1;
|
||||||
|
|
||||||
|
currBaseAddr += reservedSize;
|
||||||
|
|
||||||
ulong address = BitUtils.AlignDown(currBaseAddr, alignment) + reservedStart;
|
ulong address = BitUtils.AlignDown(currBaseAddr, alignment) + reservedStart;
|
||||||
|
|
||||||
if (currBaseAddr > address)
|
if (currBaseAddr > address)
|
||||||
|
@ -2423,9 +2425,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
|
|
||||||
ulong allocationEndAddr = address + totalNeededSize - 1;
|
ulong allocationEndAddr = address + totalNeededSize - 1;
|
||||||
|
|
||||||
if (allocationEndAddr <= regionEndAddr &&
|
if (info.Address <= address &&
|
||||||
allocationEndAddr <= currEndAddr &&
|
address < allocationEndAddr &&
|
||||||
address < allocationEndAddr)
|
allocationEndAddr <= regionEndAddr &&
|
||||||
|
allocationEndAddr <= currEndAddr)
|
||||||
{
|
{
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue