From a0bcac3904bbf51f21bf9c050369f6053a20ec1a Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Sun, 27 Aug 2023 11:09:55 +0300 Subject: [PATCH] fix: check that MIDI triggered instrument is within patch limits (#98) --- tracker/player.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tracker/player.go b/tracker/player.go index 2d2df56..2318578 100644 --- a/tracker/player.go +++ b/tracker/player.go @@ -328,6 +328,9 @@ func (p *Player) trySend(message interface{}) { func (p *Player) triggerInstrument(instrument int, note byte) { ID := idForInstrumentNote(instrument, note) p.release(ID) + if p.patch == nil || instrument < 0 || instrument >= len(p.patch) { + return + } voiceStart := p.patch.FirstVoiceForInstrument(instrument) voiceEnd := voiceStart + p.patch[instrument].NumVoices p.trigger(voiceStart, voiceEnd, note, ID)