aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjhorv <38920027+jhorv@users.noreply.github.com>2023-02-25 05:26:39 -0500
committerGitHub <noreply@github.com>2023-02-25 10:26:39 +0000
commit58207685c0dcda07d18f5f538629c775e2a714b8 (patch)
treea17f4e2c30656f306cf44ed481090639762cf14a
parent095ad923ad24c44e51ee6cee60edd50ee470fd71 (diff)
Perform bounds checking before list indexer to avoid frequent exceptions (#4438)1.1.638
* Perform bounds checking before list indexer to avoid frequent ArgumentOutOfRangeExceptions * do a single compare after casting id and .Count to uint
-rw-r--r--Ryujinx.Graphics.Vulkan/IdList.cs12
1 files changed, 10 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Vulkan/IdList.cs b/Ryujinx.Graphics.Vulkan/IdList.cs
index d5a87a05..5c0623c3 100644
--- a/Ryujinx.Graphics.Vulkan/IdList.cs
+++ b/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)
{