aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2010-01-29 01:09:41 +0000
committerWalter van Niftrik2010-01-29 01:09:41 +0000
commit5ffba8631dfba4bfb35b39a476911701b7d1034d (patch)
treec12b906655c0d7c3e0b7d478eb2c3fa7b9339546
parent981252b1fefacd9837001748e6701f4ccce109ec (diff)
downloadscummvm-rg350-5ffba8631dfba4bfb35b39a476911701b7d1034d.tar.gz
scummvm-rg350-5ffba8631dfba4bfb35b39a476911701b7d1034d.tar.bz2
scummvm-rg350-5ffba8631dfba4bfb35b39a476911701b7d1034d.zip
SCI: Fix out-of-bounds error in MT-32 patch reading in GM mode.
svn-id: r47662
-rw-r--r--engines/sci/sound/drivers/midi.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 9ce34aa9eb..8e65cb96d5 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -659,10 +659,15 @@ void MidiPlayer_Midi::mapMt32ToGm(byte *data, size_t size) {
debugCN(kDebugLevelSound, "%s -> ", Mt32PresetTimbreMaps[number].name);
break;
case 2:
- strncpy(name, (const char *)data + 0x1ec + number * 0xf6, 10);
- name[10] = 0;
- _patchMap[i] = lookupGmInstrument(name);
- debugCN(kDebugLevelSound, "%s -> ", name);
+ if (number < memtimbres) {
+ strncpy(name, (const char *)data + 0x1ec + number * 0xf6, 10);
+ name[10] = 0;
+ _patchMap[i] = lookupGmInstrument(name);
+ debugCN(kDebugLevelSound, "%s -> ", name);
+ } else {
+ _patchMap[i] = 0xff;
+ debugCN(kDebugLevelSound, "[Invalid] -> ");
+ }
break;
case 3:
_patchMap[i] = getGmInstrument(Mt32RhythmTimbreMaps[number]);