Commit fb8e88fc authored by David Gibson's avatar David Gibson

tools: Remove fd leak

compile_info() can leak an open file descriptor write_all() fails.  This
corrects it.

Found by Coverity.
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent 3c65e082
......@@ -54,8 +54,10 @@ char *compile_info(const void *ctx, const char *dir)
fd = open(info_c_file, O_WRONLY|O_CREAT|O_EXCL, 0600);
if (fd < 0)
return NULL;
if (!write_all(fd, info, tal_count(info)-1))
if (!write_all(fd, info, tal_count(info)-1)) {
close(fd);
return NULL;
}
if (close(fd) != 0)
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment