diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 81a936a30e9e..d7ad4707e795 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1703,9 +1703,11 @@ char *add_plugin_dir(struct plugins *plugins, const char *dir, bool error_ok) } else { p = plugin_register(plugins, fullpath, NULL, false, NULL, NULL); - if (!p && !error_ok) + if (!p && !error_ok) { + closedir(d); return tal_fmt(NULL, "Failed to register %s: %s", fullpath, strerror(errno)); + } } } closedir(d);