Commit 69fb897915fc56ba14c2a5e35fb55000732817b7

Edward Thomson 2020-11-21T22:54:26

midx: use GIT_ASSERT

diff --git a/src/midx.c b/src/midx.c
index 21cfff4..00d7315 100644
--- a/src/midx.c
+++ b/src/midx.c
@@ -181,7 +181,7 @@ int git_midx_parse(
 					 chunk_object_offsets = {0},
 					 chunk_object_large_offsets = {0};
 
-	assert(idx);
+	GIT_ASSERT_ARG(idx);
 
 	if (size < sizeof(struct git_midx_header) + 20)
 		return midx_error("multi-pack index is too short");
@@ -338,7 +338,7 @@ int git_midx_entry_find(
 	const unsigned char *object_offset;
 	off64_t offset;
 
-	assert(idx);
+	GIT_ASSERT_ARG(idx);
 
 	hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]);
 	lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
@@ -399,13 +399,16 @@ int git_midx_entry_find(
 	return 0;
 }
 
-void git_midx_close(git_midx_file *idx)
+int git_midx_close(git_midx_file *idx)
 {
-	assert(idx);
+	GIT_ASSERT_ARG(idx);
 
 	if (idx->index_map.data)
 		git_futils_mmap_free(&idx->index_map);
+
 	git_vector_free(&idx->packfile_names);
+
+	return 0;
 }
 
 void git_midx_free(git_midx_file *idx)
diff --git a/src/midx.h b/src/midx.h
index e6a64cd..3b80295 100644
--- a/src/midx.h
+++ b/src/midx.h
@@ -71,7 +71,7 @@ int git_midx_entry_find(
 		git_midx_file *idx,
 		const git_oid *short_oid,
 		size_t len);
-void git_midx_close(git_midx_file *idx);
+int git_midx_close(git_midx_file *idx);
 void git_midx_free(git_midx_file *idx);
 
 /* This is exposed for use in the fuzzers. */