utils: fix resource leak
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 23 Sep 2019 19:16:20 +0000 (21:16 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Mon, 23 Sep 2019 19:18:26 +0000 (21:18 +0200)
Fix resource leak in fw3_lock_path in case flock fails

Detected by Coverity in CID 1453962

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
utils.c

diff --git a/utils.c b/utils.c
index d9b1f7d..a1cba7e 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -359,6 +359,7 @@ fw3_lock_path(int *fd, const char *path)
        if (flock(lock_fd, LOCK_EX))
        {
                warn("Cannot acquire exclusive lock: %s", strerror(errno));
+               close(lock_fd);
                return false;
        }