projects
/
ccan
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3c65e08
)
tools: Remove fd leak
author
David Gibson
<david@gibson.dropbear.id.au>
Sun, 2 Apr 2017 09:17:12 +0000
(19:17 +1000)
committer
David Gibson
<david@gibson.dropbear.id.au>
Wed, 5 Apr 2017 05:56:33 +0000
(15:56 +1000)
compile_info() can leak an open file descriptor write_all() fails. This
corrects it.
Found by Coverity.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
tools/depends.c
patch
|
blob
|
history
diff --git
a/tools/depends.c
b/tools/depends.c
index e6a79d71134404e5046e714367224c9e5ed543d1..36b58092cabc10e924e42cb1669e279ccab2beb7 100644
(file)
--- 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;