aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2011-10-22 19:37:49 +0200
committerJohannes Schickel2011-10-22 19:37:49 +0200
commitd8e50b8a037de7f721491664610682f1076ca9ea (patch)
tree6be966108cf159ba99aca5ccda5f376bae8e9cbc
parent784cc2bd7fa597a4f7350ed8bca8142b15d090ea (diff)
downloadscummvm-rg350-d8e50b8a037de7f721491664610682f1076ca9ea.tar.gz
scummvm-rg350-d8e50b8a037de7f721491664610682f1076ca9ea.tar.bz2
scummvm-rg350-d8e50b8a037de7f721491664610682f1076ca9ea.zip
KYRA: Fix memory leak when a sound is started but no free handles are left.
-rw-r--r--engines/kyra/sound.cpp8
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)