From 826d1730e0668bceb329fb94f27866072c9f9159 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 8 Nov 2024 03:19:49 -0500 Subject: [PATCH] fix possible ins create type error when cursor is outside --- src/engine/engine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index fc6723502..2c25ab3b4 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -2575,6 +2575,9 @@ int DivEngine::addInstrument(int refChan, DivInstrumentType fallbackType) { DivInstrument* ins=new DivInstrument; int insCount=(int)song.ins.size(); DivInstrumentType prefType; + if (refChan>chans) { + refChan=chans-1; + } if (refChan<0) { prefType=fallbackType; } else {