summaryrefslogtreecommitdiff
path: root/src/i_oplmusic.c
diff options
context:
space:
mode:
authorSimon Howard2009-09-20 21:19:37 +0000
committerSimon Howard2009-09-20 21:19:37 +0000
commitf894f24bcd63dc8b2a0604a9b659dd95aebbb384 (patch)
tree9e3006ac7d9baa802f86a4ed5ee2ad6739ff9259 /src/i_oplmusic.c
parentb600e190fd4593faed8c14da776c991e99e8c86c (diff)
downloadchocolate-doom-f894f24bcd63dc8b2a0604a9b659dd95aebbb384.tar.gz
chocolate-doom-f894f24bcd63dc8b2a0604a9b659dd95aebbb384.tar.bz2
chocolate-doom-f894f24bcd63dc8b2a0604a9b659dd95aebbb384.zip
Avoid possible overflow due to base note offset.
Subversion-branch: /branches/opl-branch Subversion-revision: 1683
Diffstat (limited to 'src/i_oplmusic.c')
-rw-r--r--src/i_oplmusic.c7
1 files changed, 7 insertions, 0 deletions
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