odb_loose: only close file descriptor if it was opened successfully
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;
}