mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 22:28:10 +00:00
TINSEL: Code cleanup, fixed potentially undefined behavior
svn-id: r52338
This commit is contained in:
parent
2d615944fb
commit
83c8ed97e3
@ -361,7 +361,7 @@ void OpenMidiFiles() {
|
||||
|
||||
// Now scan through the contents of the MIDI file to find the offset
|
||||
// of each individual track, in order to create a mapping from MIDI
|
||||
// offset to track number, for the enhanced MIDI soundtrack
|
||||
// offset to track number, for the enhanced MIDI soundtrack.
|
||||
// The first song is always at position 4. The subsequent ones are
|
||||
// calculated dynamically.
|
||||
uint32 curOffset = 4;
|
||||
@ -373,16 +373,18 @@ void OpenMidiFiles() {
|
||||
midiOffsets[i] = 0;
|
||||
|
||||
while (!midiStream.eos() && !midiStream.err()) {
|
||||
if (curOffset + (4 * curTrack) >= (uint32)midiStream.size())
|
||||
break;
|
||||
|
||||
assert(curTrack < ARRAYSIZE(midiOffsets));
|
||||
midiOffsets[curTrack++] = curOffset + (4 * curTrack);
|
||||
//printf("%d: %d\n", curTrack - 1, midiOffsets[curTrack - 1]);
|
||||
midiOffsets[curTrack] = curOffset + (4 * curTrack);
|
||||
//printf("%d: %d\n", curTrack, midiOffsets[curTrack]);
|
||||
|
||||
songLength = midiStream.readUint32LE();
|
||||
curOffset += songLength;
|
||||
midiStream.skip(songLength);
|
||||
|
||||
if (curOffset + (4 * curTrack) >= (uint32)midiStream.size())
|
||||
break;
|
||||
curTrack++;
|
||||
}
|
||||
|
||||
midiStream.close();
|
||||
|
Loading…
Reference in New Issue
Block a user