[Scummvm-cvs-logs] SF.net SVN: scummvm:[52338] scummvm/trunk/engines/tinsel/music.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Aug 24 15:31:44 CEST 2010
Revision: 52338
http://scummvm.svn.sourceforge.net/scummvm/?rev=52338&view=rev
Author: thebluegr
Date: 2010-08-24 13:31:44 +0000 (Tue, 24 Aug 2010)
Log Message:
-----------
TINSEL: Code cleanup, fixed potentially undefined behavior
Modified Paths:
--------------
scummvm/trunk/engines/tinsel/music.cpp
Modified: scummvm/trunk/engines/tinsel/music.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/music.cpp 2010-08-24 13:11:29 UTC (rev 52337)
+++ scummvm/trunk/engines/tinsel/music.cpp 2010-08-24 13:31:44 UTC (rev 52338)
@@ -361,7 +361,7 @@
// 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 @@
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();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list