0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 18:25:46 +00:00

Make sure the string is long enough before performing basic trim (#6982)

This commit is contained in:
TSRBerry 2024-06-26 11:27:23 +02:00 committed by GitHub
parent a94445b23e
commit bd3335c143
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,8 +104,13 @@ namespace Ryujinx.UI.Common
// Find the length to trim the string to guarantee we have space for the trailing ellipsis. // Find the length to trim the string to guarantee we have space for the trailing ellipsis.
int trimLimit = byteLimit - Encoding.UTF8.GetByteCount(Ellipsis); int trimLimit = byteLimit - Encoding.UTF8.GetByteCount(Ellipsis);
// Basic trim to best case scenario of 1 byte characters. // Make sure the string is long enough to perform the basic trim.
input = input[..trimLimit]; // 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) while (Encoding.UTF8.GetByteCount(input) > trimLimit)
{ {