Skip to content

Commit 5489756

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

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Source/Standalone/InternalSynth.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ void InternalSynth::process(AudioBuffer<float>& buffer, MidiBuffer& midiMessages
166166
internalBuffer.clear();
167167

168168
// Run audio through fluidsynth
169-
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()));
169+
fluid_synth_process(synth, internalBuffer.getNumSamples(), internalBuffer.getNumChannels(), const_cast<float**>(internalBuffer.getArrayOfReadPointers()), internalBuffer.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)