From bb9272dd7af68590452cbf91b0b8583e22f0c066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 7 Jun 2011 17:03:07 +0200 Subject: [PATCH] filebuf cleanup: only unlink lockfile if we've opened it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check for the file descriptor in git_filebuf_cleanup. Without it, an existing lockfile would be deleted if we tried to acquire it (but failed, as the lockfile already existed). Signed-off-by: Carlos Martín Nieto --- src/filebuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filebuf.c b/src/filebuf.c index d0579b16b..ca13e6181 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -75,7 +75,7 @@ void git_filebuf_cleanup(git_filebuf *file) if (file->fd >= 0) gitfo_close(file->fd); - if (file->path_lock && gitfo_exists(file->path_lock) == GIT_SUCCESS) + if (file->fd >= 0 && file->path_lock && gitfo_exists(file->path_lock) == GIT_SUCCESS) gitfo_unlink(file->path_lock); if (file->digest)