summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-12-04 18:48:51 -0500
committerDavid Robillard <d@drobilla.net>2015-12-04 20:59:35 -0500
commit59601f4e1cf94c0062e6e3d343822142ec5ffecb (patch)
tree30f703627a2d07b2b03b89c4252965be88013950 /src
parentdf9e43c745dbded4c2bc0c857add921b4ca25820 (diff)
downloadlilv-59601f4e1cf94c0062e6e3d343822142ec5ffecb.tar.gz
lilv-59601f4e1cf94c0062e6e3d343822142ec5ffecb.tar.bz2
lilv-59601f4e1cf94c0062e6e3d343822142ec5ffecb.zip
Do not instantiate plugin when data fails to parse
Diffstat (limited to 'src')
-rw-r--r--src/instance.c3
-rw-r--r--src/lilv_internal.h1
-rw-r--r--src/plugin.c22
3 files changed, 23 insertions, 3 deletions
diff --git a/src/instance.c b/src/instance.c
index 5092dcd..ff7b61f 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -26,6 +26,9 @@ lilv_plugin_instantiate(const LilvPlugin* plugin,
const LV2_Feature*const* features)
{
lilv_plugin_load_if_necessary(plugin);
+ if (plugin->parse_errors) {
+ return NULL;
+ }
LilvInstance* result = NULL;
diff --git a/src/lilv_internal.h b/src/lilv_internal.h
index bdb88ed..5fc37fa 100644
--- a/src/lilv_internal.h
+++ b/src/lilv_internal.h
@@ -127,6 +127,7 @@ struct LilvPluginImpl {
LilvPort** ports;
uint32_t num_ports;
bool loaded;
+ bool parse_errors;
bool replaced;
};
diff --git a/src/plugin.c b/src/plugin.c
index 2552bff..2ed3315 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -50,6 +50,7 @@ lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri)
plugin->ports = NULL;
plugin->num_ports = 0;
plugin->loaded = false;
+ plugin->parse_errors = false;
plugin->replaced = false;
return plugin;
@@ -180,11 +181,21 @@ lilv_plugin_load(LilvPlugin* p)
sord_free(prots);
// Parse all the plugin's data files into RDF model
+ SerdStatus st = SERD_SUCCESS;
LILV_FOREACH(nodes, i, p->data_uris) {
const LilvNode* data_uri = lilv_nodes_get(p->data_uris, i);
serd_env_set_base_uri(env, sord_node_to_serd_node(data_uri->node));
- lilv_world_load_file(p->world, reader, data_uri);
+ st = lilv_world_load_file(p->world, reader, data_uri);
+ if (st > SERD_FAILURE) {
+ break;
+ }
+ }
+
+ if (st > SERD_FAILURE) {
+ p->loaded = true;
+ p->parse_errors = true;
+ return;
}
#ifdef LILV_DYN_MANIFEST
@@ -235,8 +246,8 @@ static void
lilv_plugin_load_ports_if_necessary(const LilvPlugin* const_p)
{
LilvPlugin* p = (LilvPlugin*)const_p;
- if (!p->loaded)
- lilv_plugin_load(p);
+
+ lilv_plugin_load_if_necessary(p);
if (!p->ports) {
p->ports = (LilvPort**)malloc(sizeof(LilvPort*));
@@ -433,6 +444,11 @@ lilv_plugin_get_value_internal(const LilvPlugin* p,
LILV_API bool
lilv_plugin_verify(const LilvPlugin* plugin)
{
+ lilv_plugin_load_if_necessary(plugin);
+ if (plugin->parse_errors) {
+ return false;
+ }
+
LilvNode* rdf_type = lilv_new_uri(plugin->world, LILV_NS_RDF "type");
LilvNodes* results = lilv_plugin_get_value(plugin, rdf_type);
lilv_node_free(rdf_type);