Added check to prevent queueing invalid songs, and thus reading OOB...

svn-id: r16160
This commit is contained in:
Gregory Montoir
2004-12-20 12:39:54 +00:00
parent a159f2cb76
commit 2919f4e11e
+8 -1
View File
@@ -80,6 +80,13 @@ static const byte mt32_to_gm[128] = {
}
bool MusicPlayer::queueSong(uint16 songNum) {
if (songNum >= _numSongs) {
// this happens at the end of the car chase, where we try to play song 176,
// see Sound::_tune[], entry 39
warning("Trying to queue an invalid song number %d, max %d", songNum, _numSongs);
return false;
}
uint8 emptySlots = 0;
for (int i = 0; i < MUSIC_QUEUE_SIZE; i++)
if (!_songQueue[i])
@@ -257,7 +264,7 @@ static const byte mt32_to_gm[128] = {
if (!songNum) {
stopMusic();
return;
}
}
byte *musicPtr = _musicData + songOffset(songNum);
uint32 size = songLength(songNum);