diff options
Diffstat (limited to 'engines/kyra/sound.cpp')
-rw-r--r-- | engines/kyra/sound.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index b4fcea784e..0e83c1cb1f 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -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) |