midx: use GIT_ASSERT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
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. */