diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index 91fc709f..274ea05e 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -69,10 +69,7 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context, std::string plugin_dll_path, std::string socket_endpoint_path) : io_context(main_context), - // 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())), + plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), socket_endpoint(socket_endpoint_path), host_vst_dispatch(io_context), host_vst_dispatch_midi_events(io_context), @@ -89,8 +86,9 @@ Vst2Bridge::Vst2Bridge(boost::asio::io_context& main_context, // 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( - reinterpret_cast(GetProcAddress(plugin_handle, name))); + vst_entry_point = + reinterpret_cast(reinterpret_cast( + GetProcAddress(plugin_handle.get(), name))); if (vst_entry_point != nullptr) { break; diff --git a/src/wine-host/bridges/vst2.h b/src/wine-host/bridges/vst2.h index 4dfc8598..b75b7aae 100644 --- a/src/wine-host/bridges/vst2.h +++ b/src/wine-host/bridges/vst2.h @@ -169,19 +169,10 @@ class Vst2Bridge { /** * The shared library handle of the VST plugin. I sadly could not get - * Boost.DLL to work here, so we'll just load the VST plugins by hand. - * - * FIXME: I don't know why, but `FreeLibrary()` seems to corrupt memory. - * This leads to a lot of weird behavior, such as plugins crashing as - * soon as other plugins get loaded or calls to `LoadLibrary()` - * returning null pointers while they would otherwise load fine - * without the prior call to `FreeLibrary`. We are leaking memory - * here until this is fixed, but it should not be a huge issue since - * this leak only exists for plugin groups. + * Boost.DLL to work here, so we'll just load the VST plugisn by hand. */ - // std::unique_ptr, decltype(&FreeLibrary)> - // plugin_handle; - HMODULE plugin_handle; + std::unique_ptr, decltype(&FreeLibrary)> + plugin_handle; /** * The loaded plugin's `AEffect` struct, obtained using the above library