Commit 97954ee546dc998d4424e40f360b4799afa60a1e

Colin Stolley 2022-05-20T09:06:50

Replace bitwise AND 0x7fffffff with XOR 0x80000000. Though both are correct, this makes it clear that we're dealing with the same value.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/libgit2/midx.c b/src/libgit2/midx.c
index b2f2261..98e661c 100644
--- a/src/libgit2/midx.c
+++ b/src/libgit2/midx.c
@@ -432,7 +432,7 @@ int git_midx_entry_find(
 	object_offset = idx->object_offsets + pos * 8;
 	offset = ntohl(*((uint32_t *)(object_offset + 4)));
 	if (idx->object_large_offsets && offset & 0x80000000) {
-		uint32_t object_large_offsets_pos = offset & 0x7fffffff;
+		uint32_t object_large_offsets_pos = (uint32_t) (offset ^ 0x80000000);
 		const unsigned char *object_large_offsets_index = idx->object_large_offsets;
 
 		/* Make sure we're not being sent out of bounds */