obs-vst: Fix crash on macOS when no VST bundle was loaded

When loading a function from the bundle fails, the binary is unloaded
and the reference is released, but the pointer itself is not reset -
thus the check in the unload function will succeed and try to unload
an invalid bundle reference.

Similar to Linux and Windows, the pointer needs to be explicitly set
to a null pointer to ensure this check fails.
This commit is contained in:
PatTheMav
2022-09-20 14:04:08 +02:00
committed by Ryan Foster
parent 9c3c2edd6f
commit e0f1f95c7a
+4 -4
View File
@@ -58,16 +58,16 @@ AEffect *VSTPlugin::loadEffect()
if (mainEntryPoint == NULL) {
blog(LOG_WARNING, "Couldn't get a pointer to plug-in's main()");
CFBundleUnloadExecutable(bundle);
CFRelease(bundle);
bundle = NULL;
return NULL;
}
newEffect = mainEntryPoint(hostCallback_static);
if (newEffect == NULL) {
blog(LOG_WARNING, "VST Plug-in's main() returns null.");
CFBundleUnloadExecutable(bundle);
CFRelease(bundle);
bundle = NULL;
return NULL;
}
@@ -83,7 +83,7 @@ AEffect *VSTPlugin::loadEffect()
void VSTPlugin::unloadLibrary()
{
if (bundle) {
CFBundleUnloadExecutable(bundle);
CFRelease(bundle);
bundle = NULL;
}
}
}