From a7353678a3de42c9eccfc2fd8b980ac13a2553f3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 18 Feb 2015 22:59:32 +0100 Subject: [PATCH] Actually fix Coverity CID 56281: dlopen() resource leak Signed-off-by: Joachim Nilsson --- plugin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin.c b/plugin.c index d0c5e2db..301a18a1 100644 --- a/plugin.c +++ b/plugin.c @@ -230,12 +230,14 @@ static int load_one(char *path, char *name) return 1; } - /* Remember handle from dlopen() for plugin_unregister() */ plugin = TAILQ_LAST(&plugins, plugin_head); if (!plugin) { - _e("Plugin %s failed to register.", sofile); + _e("Plugin %s failed to register, unloading from memory.", sofile); + dlclose(handle); return 1; } + + /* Remember handle from dlopen() for plugin_unregister() */ plugin->handle = handle; return 0;