KYRA: (LOL) - fix invalid use after free

It's possible for `snd_loadSoundFile` to be called with a negative track number (e.g. -1).
This commit is contained in:
Benoit Pierre 2021-10-25 19:01:00 +02:00 committed by athrxx
parent 704ed4e3b7
commit cfb9bfc8c9

View File

@ -249,7 +249,7 @@ void LoLEngine::snd_loadSoundFile(int track) {
if (_sound->musicEnabled()) {
if (_flags.platform == Common::kPlatformDOS) {
int t = (track - 250) * 3;
if (_curMusicFileIndex != _musicTrackMap[t] || _curMusicFileExt != (char)_musicTrackMap[t + 1]) {
if (t >= 0 && (_curMusicFileIndex != _musicTrackMap[t] || _curMusicFileExt != (char)_musicTrackMap[t + 1])) {
snd_stopMusic();
_sound->loadSoundFile(Common::String::format("LORE%02d%c", _musicTrackMap[t], (char)_musicTrackMap[t + 1]));
_curMusicFileIndex = _musicTrackMap[t];