Просмотр исходного кода

Fix virtual memory allocation being out of range (#2464)

gdkchan 4 лет назад
Родитель
Сommit
b5190f1681
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs

+ 7 - 4
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;
                     }