Work around a memory corruption issue on unload

I'm really not sure what is happening here, and it might just be a
winelib thing.
This commit is contained in:
Robbert van der Helm
2020-05-26 17:09:09 +02:00
parent fc35b6c9c8
commit 0c047f9a66
2 changed files with 18 additions and 7 deletions
+6 -4
View File
@@ -67,7 +67,10 @@ Vst2Bridge& get_bridge_instance(const AEffect* plugin) {
Vst2Bridge::Vst2Bridge(std::string plugin_dll_path,
std::string socket_endpoint_path)
: plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
// See `plugin_handle`s docstring for information on why we're leaking
// memory here
// : plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
: plugin_handle(LoadLibrary(plugin_dll_path.c_str())),
io_context(),
socket_endpoint(socket_endpoint_path),
host_vst_dispatch(io_context),
@@ -85,9 +88,8 @@ Vst2Bridge::Vst2Bridge(std::string plugin_dll_path,
// there are some older deprecated names that legacy plugins may still use
VstEntryPoint vst_entry_point = nullptr;
for (auto name : {"VSTPluginMain", "main_plugin", "main"}) {
vst_entry_point =
reinterpret_cast<VstEntryPoint>(reinterpret_cast<size_t>(
GetProcAddress(plugin_handle.get(), name)));
vst_entry_point = reinterpret_cast<VstEntryPoint>(
reinterpret_cast<size_t>(GetProcAddress(plugin_handle, name)));
if (vst_entry_point != nullptr) {
break;