diff options
author | jhorv <38920027+jhorv@users.noreply.github.com> | 2023-02-25 05:26:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-25 10:26:39 +0000 |
commit | 58207685c0dcda07d18f5f538629c775e2a714b8 (patch) | |
tree | a17f4e2c30656f306cf44ed481090639762cf14a | |
parent | 095ad923ad24c44e51ee6cee60edd50ee470fd71 (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.cs | 12 |
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) { |