diff options
author | David Robillard <d@drobilla.net> | 2020-01-18 17:36:06 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-01-18 17:36:06 +0100 |
commit | 5ae973b8f7f38f32a28b6b23bfe622b51bb64c51 (patch) | |
tree | e0d4a7cfe816ed63c49a95b86396670955461a0a /src | |
parent | bd0d8e69b753903888faaa781661b422793ef4be (diff) | |
download | lilv-5ae973b8f7f38f32a28b6b23bfe622b51bb64c51.tar.gz lilv-5ae973b8f7f38f32a28b6b23bfe622b51bb64c51.tar.bz2 lilv-5ae973b8f7f38f32a28b6b23bfe622b51bb64c51.zip |
Fix memory leak when dyn-manifest has no plugins
Diffstat (limited to 'src')
-rw-r--r-- | src/lilv_internal.h | 2 | ||||
-rw-r--r-- | src/plugin.c | 11 | ||||
-rw-r--r-- | src/world.c | 19 |
3 files changed, 21 insertions, 11 deletions
diff --git a/src/lilv_internal.h b/src/lilv_internal.h index 368d7ed..3a36837 100644 --- a/src/lilv_internal.h +++ b/src/lilv_internal.h @@ -424,6 +424,8 @@ lilv_dlfunc(void* handle, const char* symbol) #ifdef LILV_DYN_MANIFEST static const LV2_Feature* const dman_features = { NULL }; + +void lilv_dynmanifest_free(LilvDynManifest* dynmanifest); #endif #define LILV_ERROR(str) fprintf(stderr, "%s(): error: " str, \ diff --git a/src/plugin.c b/src/plugin.c index 3f27a6b..0743cd8 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -100,16 +100,7 @@ lilv_plugin_free(LilvPlugin* plugin) { #ifdef LILV_DYN_MANIFEST if (plugin->dynmanifest && --plugin->dynmanifest->refs == 0) { - typedef int (*CloseFunc)(LV2_Dyn_Manifest_Handle); - CloseFunc close_func = (CloseFunc)lilv_dlfunc(plugin->dynmanifest->lib, - "lv2_dyn_manifest_close"); - if (close_func) { - close_func(plugin->dynmanifest->handle); - } - - dlclose(plugin->dynmanifest->lib); - lilv_node_free(plugin->dynmanifest->bundle); - free(plugin->dynmanifest); + lilv_dynmanifest_free(plugin->dynmanifest); } #endif diff --git a/src/world.c b/src/world.c index 970111c..22d165a 100644 --- a/src/world.c +++ b/src/world.c @@ -619,7 +619,7 @@ lilv_world_load_dyn_manifest(LilvWorld* world, lilv_world_add_plugin(world, plug, manifest, desc, bundle_node); } if (desc->refs == 0) { - free(desc); + lilv_dynmanifest_free(desc); } sord_iter_free(p); sord_free(plugins); @@ -630,6 +630,23 @@ lilv_world_load_dyn_manifest(LilvWorld* world, #endif // LILV_DYN_MANIFEST } +#ifdef LILV_DYN_MANIFEST +void +lilv_dynmanifest_free(LilvDynManifest* dynmanifest) +{ + typedef int (*CloseFunc)(LV2_Dyn_Manifest_Handle); + CloseFunc close_func = (CloseFunc)lilv_dlfunc(dynmanifest->lib, + "lv2_dyn_manifest_close"); + if (close_func) { + close_func(dynmanifest->handle); + } + + dlclose(dynmanifest->lib); + lilv_node_free(dynmanifest->bundle); + free(dynmanifest); +} +#endif // LILV_DYN_MANIFEST + LilvNode* lilv_world_get_manifest_uri(LilvWorld* world, const LilvNode* bundle_uri) { |