diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-01-30 13:58:35 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-01-30 13:58:35 -0500 |
commit | 3f9f913f5302b71ef57467798f62dd3e83b217bc (patch) | |
tree | d3ec92315a41cca7d20938bccf53181d805f9f8d /bftw.c | |
parent | da51ac27f1849ad94753277650435ae482a0423f (diff) | |
download | bfs-3f9f913f5302b71ef57467798f62dd3e83b217bc.tar.xz |
bftw: Fix fd leak if fdopendir() fails.
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -234,7 +234,11 @@ static DIR *opendirat(int fd, const char *name) { return NULL; } - return fdopendir(dfd); + DIR *dir = fdopendir(dfd); + if (!dir) { + close(dfd); + } + return dir; } /** |