Skip to content

Commit

Permalink
Sas: Correct calculation of VAG end.
Browse files Browse the repository at this point in the history
Not sure why everything is negative one indexed, but this prevents reading
beyond the size of the buffer.

This shouldn't change sound output, but it may fix a crash if VAG is at
the edge of memory (unlikely, though.)
  • Loading branch information
unknownbrackets committed Jun 6, 2018
1 parent b56e3e8 commit 289928a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Core/HW/SasAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ void VagDecoder::Start(u32 data, u32 vagSize, bool loopEnabled) {
}

void VagDecoder::DecodeBlock(u8 *&read_pointer) {
if (curBlock_ == numBlocks_ - 1) {
end_ = true;
return;
}

u8 *readp = read_pointer;
int predict_nr = *readp++;
int shift_factor = predict_nr & 0xf;
Expand Down Expand Up @@ -106,9 +111,6 @@ void VagDecoder::DecodeBlock(u8 *&read_pointer) {
s_2 = s2;
curSample = 0;
curBlock_++;
if (curBlock_ == numBlocks_) {
end_ = true;
}

read_pointer = readp;
}
Expand Down

0 comments on commit 289928a

Please sign in to comment.