diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 6f66839ad4..ed2f3ce5b3 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -1056,23 +1056,29 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu throw failed_constructor (); } - if (_component->initialize (HostApplication::getHostContext ()) != kResultOk) { + if (!_component || _component->initialize (HostApplication::getHostContext ()) != kResultOk) { throw failed_constructor (); } _controller = FUnknownPtr (_component); + if (!_controller) { TUID controllerCID; if (_component->getControllerClassId (controllerCID) == kResultTrue) { if (factory->createInstance (controllerCID, Vst::IEditController::iid, (void**)&_controller) != kResultTrue) { - throw failed_constructor (); - } - if (_controller && (_controller->initialize (HostApplication::getHostContext ()) != kResultOk)) { + _component->terminate (); + _component->release (); throw failed_constructor (); } } } + if (_controller && (_controller->initialize (HostApplication::getHostContext ()) != kResultOk)) { + _component->terminate (); + _component->release (); + throw failed_constructor (); + } + if (!_controller) { _component->terminate (); _component->release ();