From e0f1f95c7af89c7ed5b003caed54e1dbc6a27a24 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Tue, 20 Sep 2022 14:04:08 +0200 Subject: [PATCH] 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. --- plugins/obs-vst/mac/VSTPlugin-osx.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/obs-vst/mac/VSTPlugin-osx.mm b/plugins/obs-vst/mac/VSTPlugin-osx.mm index 032e9e095..6ce95a12b 100644 --- a/plugins/obs-vst/mac/VSTPlugin-osx.mm +++ b/plugins/obs-vst/mac/VSTPlugin-osx.mm @@ -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; } -} \ No newline at end of file +}