Commit c3be1468 by Vicent Marti

Fix double-freeing file descriptors

Was crashing the Windows build.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent fc658755
...@@ -72,10 +72,11 @@ static int lock_file(git_filebuf *file, int flags) ...@@ -72,10 +72,11 @@ static int lock_file(git_filebuf *file, int flags)
void git_filebuf_cleanup(git_filebuf *file) void git_filebuf_cleanup(git_filebuf *file)
{ {
if (file->fd >= 0) { if (file->fd >= 0)
gitfo_close(file->fd); gitfo_close(file->fd);
if (gitfo_exists(file->path_lock) == GIT_SUCCESS)
gitfo_unlink(file->path_lock); gitfo_unlink(file->path_lock);
}
if (file->digest) if (file->digest)
git_hash_free_ctx(file->digest); git_hash_free_ctx(file->digest);
...@@ -192,6 +193,8 @@ int git_filebuf_commit(git_filebuf *file) ...@@ -192,6 +193,8 @@ int git_filebuf_commit(git_filebuf *file)
goto cleanup; goto cleanup;
gitfo_close(file->fd); gitfo_close(file->fd);
file->fd = -1;
error = gitfo_move_file(file->path_lock, file->path_original); error = gitfo_move_file(file->path_lock, file->path_original);
cleanup: cleanup:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment