From 62a2ac9fadbac2c617dfcc9647ab9933d8f35626 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Thu, 7 Oct 2010 20:24:02 +0200 Subject: more memory errors fixed in adplug ADL code --- plugins/adplug/adplug/adl.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'plugins/adplug') 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; -- cgit v1.2.3