From b1127a30c771cb37673cb82506b3fd647b5f03ae Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Thu, 20 Sep 2012 22:32:19 +0200 Subject: [PATCH] git_repository_hashfile: Only close file handle if we have a valid one Otherwise this throws an exception on MFC based systems. Signed-off-by: Sven Strickroth --- src/repository.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/repository.c b/src/repository.c index 734cab43d..1a46db0a5 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1384,7 +1384,7 @@ int git_repository_hashfile( { int error; git_vector filters = GIT_VECTOR_INIT; - git_file fd; + git_file fd = -1; git_off_t len; git_buf full_path = GIT_BUF_INIT; @@ -1435,7 +1435,8 @@ int git_repository_hashfile( error = git_odb__hashfd_filtered(out, fd, (size_t)len, type, &filters); cleanup: - p_close(fd); + if (fd >= 0) + p_close(fd); git_filters_free(&filters); git_buf_free(&full_path);