Fixes #6626: Throw if Lv2 object CTORs fail (#6951)

On plugin instantiation failure, `Lv2Proc::m_valid` was being set to false. However, `Lv2Proc::run` did not evaluate `m_valid` and still called `lilv_instance_run`, which caused undefined behavior, including crashes.

This bug fixes this by not even create such zombie classes, and instead `throw`s right away. The throws are caught in `lmms_plugin_main`, as suggested in the PR discussion and as the VST3 approach.
This commit is contained in:
Johannes Lorenz
2024-02-18 15:56:45 +01:00
committed by GitHub
parent 99120f567d
commit 34ab5ff730
9 changed files with 37 additions and 69 deletions

View File

@@ -102,9 +102,6 @@ protected:
Lv2ControlBase& operator=(const Lv2ControlBase&) = delete;
//! Must be checked after ctor or reload
bool isValid() const { return m_valid; }
/*
overrides
*/
@@ -149,7 +146,6 @@ private:
//! fulfill LMMS' requirement of having stereo input and output
std::vector<std::unique_ptr<Lv2Proc>> m_procs;
bool m_valid = true;
bool m_hasGUI = false;
unsigned m_channelsPerProc;

View File

@@ -78,8 +78,6 @@ public:
~Lv2Proc() override;
void reload();
void onSampleRateChanged();
//! Must be checked after ctor or reload
bool isValid() const { return m_valid; }
/*
port access
@@ -173,8 +171,6 @@ protected:
void shutdownPlugin();
private:
bool m_valid = true;
const LilvPlugin* m_plugin;
LilvInstance* m_instance = nullptr;
Lv2Features m_features;