From: <sv...@op...> - 2024-07-14 13:31:07
|
Author: sagamusix Date: Sun Jul 14 15:30:54 2024 New Revision: 21170 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21170 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.28/ (props changed) branches/OpenMPT-1.28/soundlib/Snd_fx.cpp Modified: branches/OpenMPT-1.28/soundlib/Snd_fx.cpp ============================================================================== --- branches/OpenMPT-1.28/soundlib/Snd_fx.cpp Sun Jul 14 15:29:02 2024 (r21169) +++ branches/OpenMPT-1.28/soundlib/Snd_fx.cpp Sun Jul 14 15:30:54 2024 (r21170) @@ -171,7 +171,7 @@ if(chn.position.GetUInt() >= sampleEnd) { - if(chn.dwFlags[CHN_LOOP]) + if(chn.dwFlags[CHN_LOOP] && loopLength) { // We exceeded the sample loop, go back to loop start. if(chn.dwFlags[CHN_PINGPONGLOOP]) @@ -1371,7 +1371,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; |