Commit 638c6b8cec27cfe73b14e00908a8a90cc0436ef1

Patrick Steinhardt 2018-02-09T17:32:15

odb_loose: only close file descriptor if it was opened successfully

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 7032b8a..470421e 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -433,7 +433,8 @@ static int read_header_loose(git_rawobj *out, git_buf *loc)
 	}
 
 done:
-	p_close(fd);
+	if (fd >= 0)
+		p_close(fd);
 	return error;
 }