From 01f56108363514812860abe2620e677a1f30b7ec Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 20 Mar 2010 20:25:37 +0000 Subject: Fix out of bounds access. svn-id: r48338 --- engines/kyra/sound.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index f25a4833a2..3ef6645d55 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -112,8 +112,9 @@ Audio::SeekableAudioStream *Sound::getVoiceStream(const char *file) { bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *handle, uint8 volume, bool isSfx) { int h = 0; - while (_mixer->isSoundHandleActive(_soundChannels[h]) && h < kNumChannelHandles) - h++; + while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h])) + ++h; + if (h >= kNumChannelHandles) return false; @@ -126,7 +127,7 @@ bool Sound::playVoiceStream(Audio::AudioStream *stream, Audio::SoundHandle *hand void Sound::voiceStop(const Audio::SoundHandle *handle) { if (!handle) { - for (int h = 0; h < kNumChannelHandles; h++) { + for (int h = 0; h < kNumChannelHandles; ++h) { if (_mixer->isSoundHandleActive(_soundChannels[h])) _mixer->stopHandle(_soundChannels[h]); } @@ -137,7 +138,7 @@ void Sound::voiceStop(const Audio::SoundHandle *handle) { bool Sound::voiceIsPlaying(const Audio::SoundHandle *handle) { if (!handle) { - for (int h = 0; h < kNumChannelHandles; h++) { + for (int h = 0; h < kNumChannelHandles; ++h) { if (_mixer->isSoundHandleActive(_soundChannels[h])) return true; } -- cgit v1.2.3