mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Adds bounds checks to resampler to avoid OOB reads
Resampling would sometimes perform an OOB read into `inputBuffer` due it not containing enough data to calculate corresponding the output sample, this has been fixed by introducing bounds checking to ensure that the buffer has enough data.
This commit is contained in:
parent
9e3b7a75b2
commit
6f59cba68d
@ -137,10 +137,13 @@ namespace skyline::audio {
|
||||
u32 lutIndex{fraction >> 8};
|
||||
|
||||
for (u8 channel{}; channel < channelCount; channel++) {
|
||||
if (((inIndex + 3) * channelCount + channel) >= inputBuffer.size())
|
||||
continue;
|
||||
|
||||
i32 data{inputBuffer[(inIndex + 0) * channelCount + channel] * lut[lutIndex].a +
|
||||
inputBuffer[(inIndex + 1) * channelCount + channel] * lut[lutIndex].b +
|
||||
inputBuffer[(inIndex + 2) * channelCount + channel] * lut[lutIndex].c +
|
||||
inputBuffer[(inIndex + 3) * channelCount + channel] * lut[lutIndex].d};
|
||||
inputBuffer[(inIndex + 1) * channelCount + channel] * lut[lutIndex].b +
|
||||
inputBuffer[(inIndex + 2) * channelCount + channel] * lut[lutIndex].c +
|
||||
inputBuffer[(inIndex + 3) * channelCount + channel] * lut[lutIndex].d};
|
||||
|
||||
outputBuffer[outIndex + channel] = Saturate<i16, i32>(data >> 15);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user