Commit 53f2c6b1d8907e1716ea4eb643868da445e36f54

lhchavez 2017-12-15T15:01:50

Simplified overflow condition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/pack.c b/src/pack.c
index e0a3938..b87d22d 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -944,11 +944,9 @@ git_off_t get_delta_base(
 			c = base_info[used++];
 			unsigned_base_offset = (unsigned_base_offset << 7) + (c & 127);
 		}
-		if ((size_t)delta_obj_offset <= unsigned_base_offset)
+		if (unsigned_base_offset == 0 || (size_t)delta_obj_offset <= unsigned_base_offset)
 			return 0; /* out of bound */
 		base_offset = delta_obj_offset - unsigned_base_offset;
-		if (base_offset >= delta_obj_offset)
-			return 0; /* out of bound */
 		*curpos += used;
 	} else if (type == GIT_OBJ_REF_DELTA) {
 		/* If we have the cooperative cache, search in it first */