From: <sv...@op...> - 2024-07-14 13:29:13
|
Author: sagamusix Date: Sun Jul 14 15:29:02 2024 New Revision: 21169 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21169 Log: Merged revision(s) 21166 from trunk/OpenMPT: [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: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/soundlib/Snd_fx.cpp Modified: branches/OpenMPT-1.29/soundlib/Snd_fx.cpp ============================================================================== --- branches/OpenMPT-1.29/soundlib/Snd_fx.cpp Sun Jul 14 15:28:29 2024 (r21168) +++ branches/OpenMPT-1.29/soundlib/Snd_fx.cpp Sun Jul 14 15:29:02 2024 (r21169) @@ -179,7 +179,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; @@ -1399,7 +1399,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; |