[APU/XMA] Prevent crash with invalid packet number

This commit is contained in:
Gliniak 2021-05-07 21:28:18 +02:00 committed by Rick Gibbed
parent 8f1f849a06
commit 57ce647bb3
1 changed files with 10 additions and 5 deletions

View File

@ -442,12 +442,17 @@ void XmaContext::Decode(XMA_CONTEXT_DATA* data) {
} else { } else {
if (data->input_buffer_read_offset % kBitsPerPacket == 0) { if (data->input_buffer_read_offset % kBitsPerPacket == 0) {
// Invalid offset. Go ahead and set it. // Invalid offset. Go ahead and set it.
int packet_number =
GetFramePacketNumber(current_input_buffer, current_input_size,
data->input_buffer_read_offset);
if (packet_number == -1) {
return;
}
auto offset = auto offset =
xma::GetPacketFrameOffset( xma::GetPacketFrameOffset(current_input_buffer +
current_input_buffer + kBytesPerPacket * packet_number) +
kBytesPerPacket * GetFramePacketNumber(
current_input_buffer, current_input_size,
data->input_buffer_read_offset)) +
data->input_buffer_read_offset; data->input_buffer_read_offset;
if (offset == -1) { if (offset == -1) {
// No more frames. // No more frames.