浏览代码

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.
PatTheMav 3 年之前
父节点
当前提交
e0f1f95c7a
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      plugins/obs-vst/mac/VSTPlugin-osx.mm

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