Avoid LM service crashes by not reading more than the buffer size (#4701)

This commit is contained in:
gdkchan 2023-04-20 12:10:17 -03:00 committed by GitHub
parent 9e50dd99d7
commit add2a9d151
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -33,6 +33,11 @@ namespace Ryujinx.Common.Memory
return data;
}
public ReadOnlySpan<byte> GetSpanSafe(int size)
{
return GetSpan((int)Math.Min((uint)_input.Length, (uint)size));
}
public T ReadAt<T>(int offset) where T : unmanaged
{
return MemoryMarshal.Cast<byte, T>(_input.Slice(offset))[0];