summaryrefslogtreecommitdiff
path: root/src/drumgizmo.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-08-04 11:37:39 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-04 11:38:46 +0200
commita2483a839264369482fff135d33f007ded266d3c (patch)
tree8303ce11ccdb32dc6a313a54dd20678739e12ac0 /src/drumgizmo.cc
parentd76db6f000844cac0afdff87e21abdf4ec009f07 (diff)
Fix crash when loading a kit with more channels than the engine was compiled for.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r--src/drumgizmo.cc12
1 files changed, 12 insertions, 0 deletions
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();