From 2ca86fe13e0efa224fbe4f374be692a8ddabdeb7 Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: May 24 2019 16:55:36 +0000 Subject: Ticket 50340 - 2nd try - structs for diabled plugins will not be freed Bug: when plugins are loaded from dse.ldif enabled plugins will be added to the list of the plugin type and freed when plugins are stopped. But the memory allocated for disabled plugins will remain allocated and and be reported. Fix: The previous fix did free not enabled plugins in plugin_setup, but that caused a lot of issues. This patch frees not enabled plugins in plugin_dependency_freeall Reviewed by: ? Signed-off-by: Mark Reynolds --- diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c index 7dfab84..0b10678 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -1914,13 +1914,18 @@ void plugin_dependency_freeall() { entry_and_plugin_t *iterp, *nextp; + char *value; /* free the plugin dependency entry list */ iterp = dep_plugin_entries; while (iterp) { nextp = iterp->next; + if ((value = slapi_entry_attr_get_charptr(iterp->e, ATTR_PLUGIN_ENABLED)) && + !strcasecmp(value, "off")) { + plugin_free(iterp->plugin); + } + slapi_ch_free_string(&value); slapi_entry_free(iterp->e); - /* plugin_free(iterp->plugin); */ slapi_ch_free((void **)&iterp); iterp = nextp; } @@ -3031,7 +3036,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, slapi_p add_plugin_entry_dn(dn_copy); } - if (add_entry && enabled) { + if (add_entry) { /* make a copy of the plugin entry for our own use because it will be freed later by the caller */ Slapi_Entry *e_copy = slapi_entry_dup(plugin_entry); @@ -3040,7 +3045,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, slapi_p } PLUGIN_CLEANUP: - if (status || !enabled) { + if (status) { plugin_free(plugin); } slapi_ch_free((void **)&configdir);