From a2483a839264369482fff135d33f007ded266d3c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 4 Aug 2021 11:37:39 +0200 Subject: Fix crash when loading a kit with more channels than the engine was compiled for. --- src/drumgizmo.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/drumgizmo.cc') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index d3665c2..abe57be 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -197,6 +197,11 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) for(size_t c = 0; c < kit.channels.size(); ++c) { + if(c >= NUM_CHANNELS) // kit may have more channels than the engine + { + break; + } + sample_t *buf = samples; bool internal = false; if(oe.getBuffer(c)) @@ -224,6 +229,11 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) size_t kitpos = pos * ratio; for(size_t c = 0; c < kit.channels.size(); ++c) { + if(c >= NUM_CHANNELS) // kit may have more channels than the engine + { + break; + } + sample_t *buf = samples; bool internal = false; if(oe.getBuffer(c)) @@ -339,6 +349,8 @@ repeat: void DrumGizmo::getSamples(int ch, int pos, sample_t* s, size_t sz) { + assert(ch < NUM_CHANNELS); + // Store local values of settings to ensure they don't change intra-iteration const auto enable_bleed_control = settings.enable_bleed_control.load(); const auto master_bleed = settings.master_bleed.load(); -- cgit v1.2.3