From: <sv...@op...> - 2024-07-14 13:28:09
|
Author: sagamusix Date: Sun Jul 14 15:27:51 2024 New Revision: 21166 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21166 Log: [Fix] Possible division by 0 when seeking with sample sync is enabled and an unused sample slot after the last used slot contains unsanitized loop information (e.g. because another format loader gave up before the current one was successful; found with afl++). Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Sun Jul 14 15:03:48 2024 (r21165) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Sun Jul 14 15:27:51 2024 (r21166) @@ -234,7 +234,7 @@ if(chn.position >= sampleEnd || (chn.position < loopStart && inc.IsNegative())) { - if(!chn.dwFlags[CHN_LOOP]) + if(!chn.dwFlags[CHN_LOOP] || !loopLength) { // Past sample end. stopNote = true; @@ -1458,7 +1458,7 @@ void CSoundFile::InstrumentChange(ModChannel &chn, uint32 instr, bool bPorta, bool bUpdVol, bool bResetEnv) const { const ModInstrument *pIns = instr <= GetNumInstruments() ? Instruments[instr] : nullptr; - const ModSample *pSmp = &Samples[instr]; + const ModSample *pSmp = &Samples[instr <= GetNumSamples() ? instr : 0]; const auto oldInsVol = chn.nInsVol; ModCommand::NOTE note = chn.nNewNote; |