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:
parent
3e5c211394
commit
7f96dbc024
@ -20,6 +20,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static int GetBufferSize<T>(int startSampleOffset, int endSampleOffset, int offset, int count) where T : unmanaged
|
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>();
|
return GetCountToDecode(startSampleOffset, endSampleOffset, offset, count) * Unsafe.SizeOf<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +264,8 @@ namespace Ryujinx.Audio.Renderer.Parameter
|
|||||||
{
|
{
|
||||||
uint dataTypeSize = (uint)Unsafe.SizeOf<T>();
|
uint dataTypeSize = (uint)Unsafe.SizeOf<T>();
|
||||||
|
|
||||||
return StartSampleOffset * dataTypeSize <= Size &&
|
return (ulong)StartSampleOffset * dataTypeSize <= Size &&
|
||||||
EndSampleOffset * dataTypeSize <= Size;
|
(ulong)EndSampleOffset * dataTypeSize <= Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user