From f894f24bcd63dc8b2a0604a9b659dd95aebbb384 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 20 Sep 2009 21:19:37 +0000 Subject: Avoid possible overflow due to base note offset. Subversion-branch: /branches/opl-branch Subversion-revision: 1683 --- src/i_oplmusic.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index de126c63..aa079614 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -934,6 +934,13 @@ static unsigned int FrequencyForVoice(opl_voice_t *voice) gm_voice = &voice->current_instr->voices[voice->current_instr_voice]; note += (signed short) SHORT(gm_voice->base_note_offset); + // Avoid possible overflow due to base note offset: + + if (note > 0x7f) + { + note = voice->note; + } + freq_index = 64 + 32 * note + voice->channel->bend; // If this is the second voice of a double voice instrument, the -- cgit v1.2.3