summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/lilv_internal.h2
-rw-r--r--src/plugin.c11
-rw-r--r--src/world.c19
4 files changed, 23 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index a57ca06..eb803d3 100644
--- a/NEWS
+++ b/NEWS
@@ -2,9 +2,10 @@ lilv (0.24.7) unstable;
* Fix cases where incorrect translation is used
* Fix deleting state bundles loaded from the model
+ * Fix memory leak when dyn-manifest has no plugins (thanks Michael Fisher)
* Implement state:freePath feature
- -- David Robillard <d@drobilla.net> Sat, 18 Jan 2020 16:10:28 +0000
+ -- David Robillard <d@drobilla.net> Sat, 18 Jan 2020 16:34:41 +0000
lilv (0.24.6) stable;
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)
{