0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-22 22:05:45 +00:00

Fix invalid audio renderer buffer size when end offset < start offset (#5588)

* Fix invalid audio renderer buffer size when end offset < start offset

* Fix possible overflow on IsSampleOffsetInRangeForPcm
This commit is contained in:
gdkchan 2023-08-20 03:56:30 -03:00 committed by GitHub
parent 3e5c211394
commit 7f96dbc024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -20,6 +20,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetBufferSize<T>(int startSampleOffset, int endSampleOffset, int offset, int count) where T : unmanaged
{
if (endSampleOffset < startSampleOffset)
{
return 0;
}
return GetCountToDecode(startSampleOffset, endSampleOffset, offset, count) * Unsafe.SizeOf<T>();
}

View file

@ -264,8 +264,8 @@ namespace Ryujinx.Audio.Renderer.Parameter
{
uint dataTypeSize = (uint)Unsafe.SizeOf<T>();
return StartSampleOffset * dataTypeSize <= Size &&
EndSampleOffset * dataTypeSize <= Size;
return (ulong)StartSampleOffset * dataTypeSize <= Size &&
(ulong)EndSampleOffset * dataTypeSize <= Size;
}
/// <summary>