From: <sv...@op...> - 2024-09-21 22:00:38
|
Author: sagamusix Date: Sun Sep 22 00:00:28 2024 New Revision: 21656 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21656 Log: [Fix] MED: Fix possible crash when loading synth/hybrid instrument with number of waveforms = 0xFFFF (special case taken from libxmp, but I don't think I have found any such file in the wild so far). Modified: trunk/OpenMPT/soundlib/Load_med.cpp Modified: trunk/OpenMPT/soundlib/Load_med.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp Sat Sep 21 12:11:47 2024 (r21655) +++ trunk/OpenMPT/soundlib/Load_med.cpp Sun Sep 22 00:00:28 2024 (r21656) @@ -999,7 +999,8 @@ TranslateMEDSynthScript(synthInstr.volTable, synthInstr.volTableLen, synthInstr.volSpeed, instrExt.hold, instrExt.decay, instr.synth.m_scripts[0], true); TranslateMEDSynthScript(synthInstr.waveTable, synthInstr.waveTableLen, synthInstr.waveSpeed, instrExt.hold, instrExt.decay, instr.synth.m_scripts[1], false); - file.ReadVector(waveformOffsets, synthInstr.numWaveforms); + if(synthInstr.numWaveforms <= 64) + file.ReadVector(waveformOffsets, synthInstr.numWaveforms); } else if(isSynth) { instr.AssignSample(0); |