getJuceChannelForVst3Channel returns -1

Hi
When running Juce plugin host, and working with VST3 plugins with multiple channels.
It is possible that the getJuceChannelForVst3Channel returns -1 if the channel is not found.
This then leads to a crash in getVst3LayoutForJuceBuffer (juce_VST3Common.h) as it tries to do this:

buffer.getWritePointer (channelStartOffset + busMap.getJuceChannelForVst3Channel ((int) I)

with the β€œ-1” it got from getJuceChannelForVst3Channel. this will then crash.

So could we please guard against the -1?

Maybe this is an edge case, and my real problem is probably something else. I don’t know why it returns -1 but it seems like something that could fail more gracefully.

Thanks for reporting. When I tested this, it looked like the issue was caused when JUCE requested channel layouts that could not be represented as VST3 speaker arrangements. I’ve now added some safeguards to avoid setting channel layouts that have no corresponding VST3 representation:

1 Like