diff options
author | David Robillard <d@drobilla.net> | 2013-05-30 23:09:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-05-30 23:09:29 +0000 |
commit | 028c8ed8661e925177e1aa9fb2497290838db9cf (patch) | |
tree | 0040b21034851b1040fbcc227e2989bc3df399bc | |
parent | 3c45957cdb38a115d013dd5d96f60b6ee1320229 (diff) | |
download | lilv-028c8ed8661e925177e1aa9fb2497290838db9cf.tar.gz lilv-028c8ed8661e925177e1aa9fb2497290838db9cf.tar.bz2 lilv-028c8ed8661e925177e1aa9fb2497290838db9cf.zip |
Fix unlikely memory leak in lilv_plugin_instantiate().
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5115 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/instance.c | 16 |
2 files changed, 10 insertions, 9 deletions
@@ -2,9 +2,10 @@ lilv (0.16.1) unstable; * Allow lilv_state_restore() to be used without passing an instance, for restoring port values via a callback only + * Fix unlikely memory leak in lilv_plugin_instantiate() * lilvmm.hpp: Add wrappers for UI API - -- David Robillard <d@drobilla.net> Tue, 19 Mar 2013 00:01:12 -0400 + -- David Robillard <d@drobilla.net> Thu, 30 May 2013 19:09:07 -0400 lilv (0.16.0) stable; diff --git a/src/instance.c b/src/instance.c index 5fa47fa..ea109d5 100644 --- a/src/instance.c +++ b/src/instance.c @@ -31,12 +31,6 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, LilvInstance* result = NULL; - const LV2_Feature** local_features = NULL; - if (features == NULL) { - local_features = (const LV2_Feature**)malloc(sizeof(LV2_Feature)); - local_features[0] = NULL; - } - const LilvNode* const lib_uri = lilv_plugin_get_library_uri(plugin); const LilvNode* const bundle_uri = lilv_plugin_get_bundle_uri(plugin); @@ -56,6 +50,12 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, return NULL; } + const LV2_Feature** local_features = NULL; + if (features == NULL) { + local_features = (const LV2_Feature**)malloc(sizeof(LV2_Feature)); + local_features[0] = NULL; + } + // Search for plugin by URI for (uint32_t i = 0; true; ++i) { const LV2_Descriptor* ld = lilv_lib_get_plugin(lib, i); @@ -93,6 +93,8 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, } } + free(local_features); + if (result) { // Failed to instantiate if (result->lv2_handle == NULL) { @@ -105,8 +107,6 @@ lilv_plugin_instantiate(const LilvPlugin* plugin, result->lv2_descriptor->connect_port(result->lv2_handle, i, NULL); } - free(local_features); - return result; } |