Skip to content

Commit b4daf94

Browse files
committed
Fix potential crash caused by internal GM synth
1 parent e2afa5f commit b4daf94

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Source/Standalone/InternalSynth.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ void InternalSynth::process(AudioBuffer<float>& buffer, MidiBuffer& midiMessages
168168
// Run audio through fluidsynth
169169
fluid_synth_process(synth, buffer.getNumSamples(), std::max(2, buffer.getNumChannels()), const_cast<float**>(internalBuffer.getArrayOfReadPointers()), std::max(2, buffer.getNumChannels()), const_cast<float**>(internalBuffer.getArrayOfWritePointers()));
170170

171-
for (int ch = 0; ch < buffer.getNumChannels(); ch++) {
171+
int numChannelsToProcess = std::min(buffer.getNumChannels(), internalBuffer.getNumChannels());
172+
for (int ch = 0; ch < numChannelsToProcess; ch++) {
172173
buffer.addFrom(ch, 0, internalBuffer, ch, 0, buffer.getNumSamples());
173174
}
174175

0 commit comments

Comments
 (0)