From fb8e88fce366e0379e7f6098183145633a8afeae Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 2 Apr 2017 19:17:12 +1000 Subject: [PATCH] tools: Remove fd leak compile_info() can leak an open file descriptor write_all() fails. This corrects it. Found by Coverity. Signed-off-by: David Gibson --- tools/depends.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/depends.c b/tools/depends.c index e6a79d71..36b58092 100644 --- a/tools/depends.c +++ b/tools/depends.c @@ -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; -- 2.39.2