I’ve got some plugins that are crashing below because the presets array is nullptr even after they report a size of 8. Adding a nullptr check seems to fix the problem:
in juce_AudioUnitPluginFormat.mm from line 1207
int getNumPrograms() override
{
CFArrayRef presets;
UInt32 sz = sizeof (CFArrayRef);
int num = 0;
if (AudioUnitGetProperty (audioUnit, kAudioUnitProperty_FactoryPresets,
kAudioUnitScope_Global, 0, &presets, &sz) == noErr)
{
if (presets != nullptr)
{
num = (int) CFArrayGetCount (presets);
CFRelease (presets);
}
}
return num;
}
Where are you seeing this crash? Might it be better to do the following, so we don’t just early-return and still call CFRelease(), sendAllParametersChangedEvents() etc.:
That’s fine with me, thanks. Steps to reproduce this crash: use the JUCE plugin host, load an Audio Unit that has no programs (e.g. Gulfoss by Soundtheory). Calling getCurrentProgram() returns 0, but setCurrentProgram(0) leads to that crash. One could argue that it’s stupid to set a program when there are no programs, but still, it shouldn’t crash.