From f9b70f1d39013cabe0f7d6a39e30d2523e947e66 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 27 Aug 2025 15:44:22 +0100 Subject: [PATCH] LV2 Host: Fix leak of plugin classes when scanning plugins multiple times --- modules/juce_audio_processors/format_types/LV2_SDK/README.md | 2 ++ .../format_types/LV2_SDK/lilv/src/world.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_processors/format_types/LV2_SDK/README.md b/modules/juce_audio_processors/format_types/LV2_SDK/README.md index e4b02ab560..7d6e748919 100644 --- a/modules/juce_audio_processors/format_types/LV2_SDK/README.md +++ b/modules/juce_audio_processors/format_types/LV2_SDK/README.md @@ -7,6 +7,8 @@ directory. The following modifications were made: - Removed the include of dlfcn.h in world.c - Fixed a leak of world->opt.lv2_path when calling lilv_world_set_option multiple times +- Fixed a leak of plugin classes when calling lilv_world_load_plugin_classes + multiple times Remember to update the versions in the config headers if you ever update the library versions! diff --git a/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src/world.c b/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src/world.c index 3a601ab85c..5f1818dc7a 100644 --- a/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src/world.c +++ b/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src/world.c @@ -1046,7 +1046,8 @@ lilv_world_load_plugin_classes(LilvWorld* world) LilvPluginClass* pclass = lilv_plugin_class_new( world, parent, class_node, (const char*)sord_node_get_string(label)); if (pclass) { - zix_tree_insert((ZixTree*)world->plugin_classes, pclass, NULL); + if (zix_tree_insert((ZixTree*)world->plugin_classes, pclass, NULL) == ZIX_STATUS_EXISTS) + lilv_plugin_class_free(pclass); } sord_node_free(world->world, label);