Commit 8f189cbfed621d5c6dfaa3ccdc8ea6b382ec0834

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 6729614..7df6efd 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 */