diff options
Diffstat (limited to 'src/plugininstance.c')
-rw-r--r-- | src/plugininstance.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/plugininstance.c b/src/plugininstance.c index be2252c..62b4c7d 100644 --- a/src/plugininstance.c +++ b/src/plugininstance.c @@ -99,20 +99,21 @@ slv2_plugin_instantiate(SLV2Plugin plugin, } } - assert(result); - assert(slv2_plugin_get_num_ports(plugin) > 0); + if (result) { + assert(slv2_plugin_get_num_ports(plugin) > 0); + + // Failed to instantiate + if (result->lv2_handle == NULL) { + //printf("Failed to instantiate %s\n", plugin->plugin_uri); + free(result); + return NULL; + } - // Failed to instantiate - if (result->lv2_handle == NULL) { - //printf("Failed to instantiate %s\n", plugin->plugin_uri); - free(result); - return NULL; + // "Connect" all ports to NULL (catches bugs) + for (uint32_t i=0; i < slv2_plugin_get_num_ports(plugin); ++i) + result->lv2_descriptor->connect_port(result->lv2_handle, i, NULL); } - // "Connect" all ports to NULL (catches bugs) - for (uint32_t i=0; i < slv2_plugin_get_num_ports(plugin); ++i) - result->lv2_descriptor->connect_port(result->lv2_handle, i, NULL); - if (local_host_features) free(host_features); @@ -123,6 +124,9 @@ slv2_plugin_instantiate(SLV2Plugin plugin, void slv2_instance_free(SLV2Instance instance) { + if (!instance) + return; + struct _Instance* i = (struct _Instance*)instance; i->lv2_descriptor->cleanup(i->lv2_handle); i->lv2_descriptor = NULL; |