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 d9b1f7dc2d78e827786fe36c1a928e2aa3a6613c..a1cba7ecccee8f6b4f2f1ae34f8af3234f2a7eeb 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;
        }