From 1edad44252f54b58f7a8be9a0b59b35222fb0e8c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 13 Oct 2022 01:53:12 +0200 Subject: Actually cleanup after ourselves --- src/luxinit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/luxinit.c') 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 #include +#include #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; } -- cgit v1.2.3