diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-10-07 20:24:02 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-10-07 20:24:02 +0200 |
commit | 62a2ac9fadbac2c617dfcc9647ab9933d8f35626 (patch) | |
tree | 085afc49a77508478b9a3844eea63f83c5539409 /plugins/adplug | |
parent | 6fdae5d00105250e65d8577031f2b43b2bf43019 (diff) |
more memory errors fixed in adplug ADL code
Diffstat (limited to 'plugins/adplug')
-rw-r--r-- | plugins/adplug/adplug/adl.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/adplug/adplug/adl.cpp b/plugins/adplug/adplug/adl.cpp index 13ddd222..6febbf87 100644 --- a/plugins/adplug/adplug/adl.cpp +++ b/plugins/adplug/adplug/adl.cpp @@ -778,8 +778,19 @@ void AdlibDriver::executePrograms() { opcode &= 0x7F; if (opcode >= _parserOpcodeTableSize) opcode = _parserOpcodeTableSize - 1; - debugC(9, kDebugLevelSound, "Calling opcode '%s' (%d) (channel: %d)", _parserOpcodeTable[opcode].name, opcode, _curChannel); - result = (this->*(_parserOpcodeTable[opcode].function))(dataptr, channel, param); + debugC(9, kDebugLevelSound, "Calling opcode '%s' (%d) (channel: %d)\n", _parserOpcodeTable[opcode].name, opcode, _curChannel); + if (opcode == 2) { + int offset = READ_LE_UINT16(_soundData + 2 * param); + if (offset == 0xffff) { + break; // corrupted file / bad parser + } + else { + result = (this->*(_parserOpcodeTable[opcode].function))(dataptr, channel, param); + } + } + else { + result = (this->*(_parserOpcodeTable[opcode].function))(dataptr, channel, param); + } channel.dataptr = dataptr; if (result) break; |