From 8e0447e9262aada3bc0753b3ce1707dccf3949ab Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 31 May 2016 13:10:35 +0200 Subject: AUDIO: Fix memory corruption. Since it was --voice, we were reading element index -1. --- audio/mods/maxtrax.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/mods/maxtrax.cpp b/audio/mods/maxtrax.cpp index f5754a5f96..b0cdaef95a 100644 --- a/audio/mods/maxtrax.cpp +++ b/audio/mods/maxtrax.cpp @@ -708,7 +708,7 @@ int8 MaxTrax::noteOn(ChannelContext &channel, const byte note, uint16 volume, ui voiceNum = pickvoice((channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 1 : 0, pri); } else { VoiceContext *voice = ARRAYEND(_voiceCtx); - for (voiceNum = ARRAYSIZE(_voiceCtx); voiceNum-- != 0 && --voice->channel != &channel;) + for (voiceNum = ARRAYSIZE(_voiceCtx); voiceNum >= 0 && voice->channel != &channel; voiceNum--, voice--) ; if (voiceNum < 0) voiceNum = pickvoice((channel.flags & ChannelContext::kFlagRightChannel) != 0 ? 1 : 0, pri); -- cgit v1.2.3