LV2: fix crash when replicating stateful plugin on copy

When copying a mono LV2 plugin to a stereo track, the
state of the copied mono plugin is copied to the replicated
instance.

However at this point in time PBD::Stateful::ForceIDRegeneration
is still enabled, and the state ID has not been set.

This used to not be an issue. Older versions of liblilv
handle non-existent paths just fine.

However in lilv v0.24.20-10-gdd5e851 `lilv_path_absolute`
was replaced with `zix_canonical_path` which returns NULL
if a state file does not [yet] exist. This lead to a segfault
due to strlen(NULL) in `serd_node_new_file_uri`:

#0 strlen -- SEGV on unknown address 0x000000000000
#1 serd_node_new_file_uri () at /lib/x86_64-linux-gnu/libserd-0.so.0
#2 lilv_state_new_from_file () at /lib/x86_64-linux-gnu/liblilv-0.so.0
#3 ARDOUR::LV2Plugin::set_state(XMLNode const&, int) at ../libs/ardour/lv2_plugin.cc:2320
This commit is contained in:
Robin Gareus 2023-12-15 04:28:23 +01:00
parent 6c5d15a1e6
commit 066df7cc1a
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -180,6 +180,7 @@ PluginInsert::set_count (uint32_t num)
add_plugin (p);
if (require_state) {
_plugins[0]->set_insert_id (this->id ());
XMLNode& state = _plugins[0]->get_state ();
p->set_state (state, Stateful::current_state_version);
delete &state;