diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-07-11 16:24:31 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 16:24:31 -0300 |
commit | b5190f16810eb77388c861d1d1773e19644808db (patch) | |
tree | be856ba3e68e78993223b3bf9fa6c42ec4bff861 /Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs | |
parent | 0d841c8d5104a09d2733c0e78f6d5b7ebc8fee3e (diff) |
Fix virtual memory allocation being out of range (#2464)
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs b/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs index a2db8dcc..e1ab0b93 100644 --- a/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs +++ b/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs @@ -2411,9 +2411,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory { 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; + currBaseAddr += reservedSize; + ulong address = BitUtils.AlignDown(currBaseAddr, alignment) + reservedStart; if (currBaseAddr > address) @@ -2423,9 +2425,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory ulong allocationEndAddr = address + totalNeededSize - 1; - if (allocationEndAddr <= regionEndAddr && - allocationEndAddr <= currEndAddr && - address < allocationEndAddr) + if (info.Address <= address && + address < allocationEndAddr && + allocationEndAddr <= regionEndAddr && + allocationEndAddr <= currEndAddr) { return address; } |