mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 23:52:41 +00:00
SWORD1: Fix use of uninitialized variables in PSX demo music
The music tab file in the PSX demo seems to be truncated and we were seeking beyond the end of the file for some music (such as the one for the menu), and then trying to read without any checks that either the seek or read succeeded. This caused the code to then use uninitialized variables causing random issues (such as getting some noise). We now ignore the music id that are beyond the end of the broken tab file.
This commit is contained in:
parent
899ae85846
commit
20fb33a668
@ -121,7 +121,12 @@ bool MusicHandle::playPSX(uint16 id, bool loop) {
|
||||
if (!tableFile.open("tunes.tab"))
|
||||
return false;
|
||||
|
||||
tableFile.seek((id - 1) * 8, SEEK_SET);
|
||||
// The PSX demo has a broken/truncated tunes.tab. So we check here that the offset is not
|
||||
// beyond the end of the file.
|
||||
int32 tableOffset = (id - 1) * 8;
|
||||
if (tableOffset >= tableFile.size())
|
||||
return false;
|
||||
tableFile.seek(tableOffset, SEEK_SET);
|
||||
uint32 offset = tableFile.readUint32LE() * 0x800;
|
||||
uint32 size = tableFile.readUint32LE();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user