Skip to content

Commit

Permalink
lightningd: close plugin dir on return
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
morehouse authored and cdecker committed Jun 5, 2023
1 parent e81bf8b commit 4f30857
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4f30857

Please sign in to comment.