summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2016-11-15 11:24:24 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2016-11-15 11:24:24 +0100
commit66cfb039ce7127f853ef7b7791e91679065edd87 (patch)
tree19634778ef8fa07bcb03075c8ebab68ce099b151
parentf5ea9d4a5fca10089e79cf6149364f5013304192 (diff)
downloadlibgit2-cmn/sortedcache-close.tar.gz
sortedcache: close the fd on stat trouble as wellcmn/sortedcache-close
As Coverity pointed out, we fail to close the file handle if we have trouble during the stat call. This is unlikely to result in real leaks as stat errors should be very rare, but do make sure to close the fd.
-rw-r--r--src/sortedcache.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/sortedcache.c b/src/sortedcache.c
index ed4199b71..5bd989a9f 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -216,6 +216,7 @@ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf)
if (p_fstat(fd, &st) < 0) {
giterr_set(GITERR_OS, "failed to stat file");
error = -1;
+ (void)p_close(fd);
goto unlock;
}