diff options
author | Thomas Voss <mail@thomasvoss.com> | 2022-10-13 01:53:12 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2022-10-13 01:53:12 +0200 |
commit | 1edad44252f54b58f7a8be9a0b59b35222fb0e8c (patch) | |
tree | cebea00cf6b44aa5185b578195f720817d4f1452 /src/luxinit.c | |
parent | 9f313f400758931b34229db0e2a67b303987bc69 (diff) |
Actually cleanup after ourselvesv1.0.0
Diffstat (limited to 'src/luxinit.c')
-rw-r--r-- | src/luxinit.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/luxinit.c b/src/luxinit.c index ae25925..949f3a2 100644 --- a/src/luxinit.c +++ b/src/luxinit.c @@ -19,6 +19,7 @@ #include <dirent.h> #include <fcntl.h> +#include <unistd.h> #include "lux.h" @@ -54,15 +55,19 @@ getdir(void) * Finally we open the folder so that we have a file descriptor we can * return. */ - if ((dfd = open(LUX_BACKLIGHT_DIR, O_RDONLY)) == -1 - || (dir = fdopendir(dfd)) == NULL) + if ((dfd = open(LUX_BACKLIGHT_DIR, O_RDONLY)) == -1) return -1; + if ((dir = fdopendir(dfd)) == NULL) { + close(dfd); + return -1; + } if ((dp = readdir(dir)) == NULL || (dp = readdir(dir)) == NULL || (dp = readdir(dir)) == NULL || (fd = openat(dfd, dp->d_name, LUX_GDIR_FLAGS)) == -1) fd = -1; + close(dfd); closedir(dir); return fd; } |