lightningd: close plugin dir on return

Memory leak detected by ASan:

==880002==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32816 byte(s) in 1 object(s) allocated from:
    #0 0x5039e7 in malloc (lightningd/lightningd+0x5039e7)
    #1 0x7f2e8c203884 in __alloc_dir (/lib64/libc.so.6+0xd2884)
This commit is contained in:
Matt Morehouse
2023-04-12 17:25:06 -05:00
committed by Christian Decker
parent e81bf8b89f
commit 4f30857401

View File

@@ -1703,9 +1703,11 @@ char *add_plugin_dir(struct plugins *plugins, const char *dir, bool error_ok)
} else { } else {
p = plugin_register(plugins, fullpath, NULL, false, p = plugin_register(plugins, fullpath, NULL, false,
NULL, NULL); NULL, NULL);
if (!p && !error_ok) if (!p && !error_ok) {
closedir(d);
return tal_fmt(NULL, "Failed to register %s: %s", return tal_fmt(NULL, "Failed to register %s: %s",
fullpath, strerror(errno)); fullpath, strerror(errno));
}
} }
} }
closedir(d); closedir(d);