diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2024-06-26 11:27:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 11:27:23 +0200 |
commit | bd3335c143d2420875ff6ea0abd7487deb5a9ddc (patch) | |
tree | 062968af056efd526bee18faedd56400a6a2f2dd | |
parent | a94445b23e408707c595ad1833b9bf1fd89e3335 (diff) |
Make sure the string is long enough before performing basic trim (#6982)1.1.1339
-rw-r--r-- | src/Ryujinx.UI.Common/DiscordIntegrationModule.cs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs b/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs index fb07195d..6966038b 100644 --- a/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs +++ b/src/Ryujinx.UI.Common/DiscordIntegrationModule.cs @@ -104,8 +104,13 @@ namespace Ryujinx.UI.Common // Find the length to trim the string to guarantee we have space for the trailing ellipsis. int trimLimit = byteLimit - Encoding.UTF8.GetByteCount(Ellipsis); - // Basic trim to best case scenario of 1 byte characters. - input = input[..trimLimit]; + // Make sure the string is long enough to perform the basic trim. + // Amount of bytes != Length of the string + if (input.Length > trimLimit) + { + // Basic trim to best case scenario of 1 byte characters. + input = input[..trimLimit]; + } while (Encoding.UTF8.GetByteCount(input) > trimLimit) { |