diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/node.c | 14 | ||||
-rw-r--r-- | utils/lv2info.c | 8 |
3 files changed, 20 insertions, 3 deletions
@@ -4,6 +4,7 @@ lilv (9999) unstable; * Deprecate old flawed Lilv::Instance constructors * Add Lilv::Instance::get_handle() and Lilv::Instance::get_extension_data() * Fix documentation for ui_type parameter of lilv_ui_is_supported() + * Fix crash when lv2info is run with an invalid URI argument -- David Robillard <d@drobilla.net> @@ -60,11 +60,10 @@ lilv_node_new(LilvWorld* world, LilvNodeType type, const char* str) switch (type) { case LILV_VALUE_URI: val->val.uri_val = sord_new_uri(world->world, (const uint8_t*)str); - val->str_val = (char*)sord_node_get_string(val->val.uri_val); break; case LILV_VALUE_BLANK: val->val.uri_val = sord_new_blank(world->world, (const uint8_t*)str); - val->str_val = (char*)sord_node_get_string(val->val.uri_val); + break; case LILV_VALUE_STRING: case LILV_VALUE_INT: case LILV_VALUE_FLOAT: @@ -74,6 +73,17 @@ lilv_node_new(LilvWorld* world, LilvNodeType type, const char* str) break; } + switch (type) { + case LILV_VALUE_URI: + case LILV_VALUE_BLANK: + if (!val->val.uri_val) { + free(val); + return NULL; + } + val->str_val = (char*)sord_node_get_string(val->val.uri_val); + default: break; + } + return val; } diff --git a/utils/lv2info.c b/utils/lv2info.c index 101f9dc..53ad3d9 100644 --- a/utils/lv2info.c +++ b/utils/lv2info.c @@ -379,6 +379,13 @@ main(int argc, char** argv) LilvWorld* world = lilv_world_new(); lilv_world_load_all(world); + LilvNode* uri = lilv_new_uri(world, plugin_uri); + if (!uri) { + fprintf(stderr, "Invalid plugin URI\n"); + lilv_world_free(world); + return 1; + } + applies_to_pred = lilv_new_uri(world, LV2_CORE__appliesTo); control_class = lilv_new_uri(world, LILV_URI_CONTROL_PORT); event_class = lilv_new_uri(world, LILV_URI_EVENT_PORT); @@ -389,7 +396,6 @@ main(int argc, char** argv) supports_event_pred = lilv_new_uri(world, LV2_EVENT__supportsEvent); const LilvPlugins* plugins = lilv_world_get_all_plugins(world); - LilvNode* uri = lilv_new_uri(world, plugin_uri); const LilvPlugin* p = lilv_plugins_get_by_uri(plugins, uri); if (p && plugin_file) { |