Skip to content

Commit

Permalink
KYRA: Fix memory leak when a sound is started but no free handles are…
Browse files Browse the repository at this point in the history
… left.

(cherry picked from commit d8e50b8)
  • Loading branch information
Johannes Schickel committed Oct 22, 2011
1 parent d80284d commit af32b71
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion engines/kyra/sound.cpp
Expand Up @@ -109,8 +109,14 @@ bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *hand
while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h]))
++h;

if (h >= kNumChannelHandles)
if (h >= kNumChannelHandles) {
// When we run out of handles we need to destroy the stream object,
// this is to avoid memory leaks in some scenes where too many sfx
// are started.
// See bug #3427240 "LOL-CD: Memory leak in caves level 3".
delete stream;
return false;
}

_mixer->playStream(isSfx ? Audio::Mixer::kSFXSoundType : Audio::Mixer::kSpeechSoundType, &_soundChannels[h], stream, -1, volume);
if (handle)
Expand Down

0 comments on commit af32b71

Please sign in to comment.