summaryrefslogtreecommitdiff
path: root/src/filebuf.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-02-24 19:31:12 +0200
committerVicent Marti <tanoku@gmail.com>2011-02-24 19:31:12 +0200
commitc3be146840754d881655fb6b851899fb4a0d7cbd (patch)
tree67fb010dc0d42fc08a3912067cc13cf38f40f8e0 /src/filebuf.c
parentfc658755bf980170cf5a497870155a9fc97151cb (diff)
downloadlibgit2-c3be146840754d881655fb6b851899fb4a0d7cbd.tar.gz
Fix double-freeing file descriptors
Was crashing the Windows build. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/filebuf.c')
-rw-r--r--src/filebuf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/filebuf.c b/src/filebuf.c
index ace7428e0..1359f11d1 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -72,10 +72,11 @@ static int lock_file(git_filebuf *file, int flags)
void git_filebuf_cleanup(git_filebuf *file)
{
- if (file->fd >= 0) {
+ if (file->fd >= 0)
gitfo_close(file->fd);
+
+ if (gitfo_exists(file->path_lock) == GIT_SUCCESS)
gitfo_unlink(file->path_lock);
- }
if (file->digest)
git_hash_free_ctx(file->digest);
@@ -192,6 +193,8 @@ int git_filebuf_commit(git_filebuf *file)
goto cleanup;
gitfo_close(file->fd);
+ file->fd = -1;
+
error = gitfo_move_file(file->path_lock, file->path_original);
cleanup: