Commit 494448a5eb723b4d47a8cc97321f7f7375150465

Edward Thomson 2019-01-20T19:10:08

index: explicitly cast down to a size_t Quiet down a warning from MSVC about how we're potentially losing data. This cast is safe since we've explicitly tested that `strip_len` <= `last_len`.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/index.c b/src/index.c
index 8b75323..7f865c2 100644
--- a/src/index.c
+++ b/src/index.c
@@ -2475,7 +2475,7 @@ static int read_entry(
 		if (varint_len == 0 || last_len < strip_len)
 			return index_error_invalid("incorrect prefix length");
 
-		prefix_len = last_len - strip_len;
+		prefix_len = last_len - (size_t)strip_len;
 		suffix_len = strlen(path_ptr + varint_len);
 
 		GIT_ERROR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len);