]> git.proxmox.com Git - libgit2.git/commitdiff
filebuf cleanup: only unlink lockfile if we've opened it
authorCarlos Martín Nieto <cmn@elego.de>
Tue, 7 Jun 2011 15:03:07 +0000 (17:03 +0200)
committerCarlos Martín Nieto <cmn@elego.de>
Tue, 7 Jun 2011 15:05:40 +0000 (17:05 +0200)
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 <cmn@elego.de>
src/filebuf.c

index d0579b16b6bed24733e6732bffc8d047e53c2f75..ca13e6181d8ce8f0c10a1091bf820deb9fcae6b7 100644 (file)
@@ -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)