1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-21 03:22:00 +00:00

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
This commit is contained in:
jhorv 2023-02-25 05:26:39 -05:00 committed by GitHub
parent 095ad923ad
commit 58207685c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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