From 4f83b70f690f437b983333a7c43def3ed6ca2d46 Mon Sep 17 00:00:00 2001 From: Alexander Larsson <alexl@redhat.com> Date: Tue, 28 Jun 2016 11:23:47 +0200 Subject: [PATCH] glnx_release_lock_file - Don't close fd -1 (i.e. if we never locked) This happens a lot if you use autocleanup for lock files, and the function returns early without the lock being taken. --- glnx-lockfile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glnx-lockfile.c b/glnx-lockfile.c index be9ad3a07..7dd69e91f 100644 --- a/glnx-lockfile.c +++ b/glnx-lockfile.c @@ -187,7 +187,8 @@ void glnx_release_lock_file(GLnxLockFile *f) { f->path = NULL; } - (void) close (f->fd); + if (f->fd != -1) + (void) close (f->fd); f->fd = -1; f->operation = 0; } -- GitLab