aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2025-05-23 22:36:53 +0300
committerWohlstand <admin@wohlnet.ru>2025-05-23 22:36:53 +0300
commiteb7014e8f8772cc37462c2398a8f3a602e7a8302 (patch)
tree27e2d9794ecaf3a9aac8c14ef25930c5af1f9c36 /src
parent91558f59359eedef8d67dacacb838da498e3c3ef (diff)
downloadlibADLMIDI-eb7014e8f8772cc37462c2398a8f3a602e7a8302.tar.gz
libADLMIDI-eb7014e8f8772cc37462c2398a8f3a602e7a8302.tar.bz2
libADLMIDI-eb7014e8f8772cc37462c2398a8f3a602e7a8302.zip
Fixed a crash because of invalid user of chip channel
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi_midiplay.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 2383d26..33a812d 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -1565,12 +1565,23 @@ bool MIDIplay::killSecondVoicesIfOverflow(int32_t &new_chan)
{
AdlChannel::users_iterator j = &m_chipChannels[new_chan].users.front();
AdlChannel::LocationData &jd = j->value;
- MIDIchannel::notes_iterator i(m_midiChannels[jd.loc.MidCh].ensure_find_activenote(jd.loc.note));
+ MIDIchannel::notes_iterator it = m_midiChannels[jd.loc.MidCh].find_activenote(jd.loc.note);
- if(i->value.chip_channels_count == 2)
+ if(it.is_end()) /* Invalid user of channel */
{
m_chipChannels[new_chan].users.erase(j);
- i->value.chip_channels_count = 1;
+ m_chipChannels[new_chan].koff_time_until_neglible_us = 0;
+ ret = true;
+ return ret;
+ }
+
+ MIDIchannel::NoteInfo &info = it->value;
+
+ if(info.chip_channels_count == 2)
+ {
+ m_chipChannels[new_chan].users.erase(j);
+ m_chipChannels[new_chan].koff_time_until_neglible_us = 0;
+ info.phys_erase_at(&info.chip_channels[1]);
ret = true;
}
}