Small Workaround for Crashing AU Plugins

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;
    }

That sounds sensible, I’ll get it added. Thanks!

1 Like