فهرست منبع

Perform bounds checking before list indexer to avoid frequent exceptions (#4438)

* Perform bounds checking before list indexer to avoid frequent ArgumentOutOfRangeExceptions

* do a single compare after casting id and .Count to uint
jhorv 3 سال پیش
والد
کامیت
58207685c0
1فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  1. 10 2
      Ryujinx.Graphics.Vulkan/IdList.cs

+ 10 - 2
Ryujinx.Graphics.Vulkan/IdList.cs

@@ -80,8 +80,16 @@ namespace Ryujinx.Graphics.Vulkan
 
             try
             {
-                value = _list[id];
-                return value != null;
+                if ((uint)id < (uint)_list.Count)
+                {
+                    value = _list[id];
+                    return value != null;
+                }
+                else
+                {
+                    value = null;
+                    return false;
+                }
             }
             catch (ArgumentOutOfRangeException)
             {