summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-07-09 22:25:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-07-09 22:25:38 (GMT)
commit891c1c280f070998428868d9a175c89341f8c982 (patch)
tree8678828ba73e9a971237cbcfb58426789000c143 /builtin
parent1b074e15d0f976be2bc14f9528874a841c055213 (diff)
parent568a05c5ecb8e3a01fcb90d0f81857f49ef2add8 (diff)
downloadgit-891c1c280f070998428868d9a175c89341f8c982.zip
git-891c1c280f070998428868d9a175c89341f8c982.tar.gz
git-891c1c280f070998428868d9a175c89341f8c982.tar.bz2
Merge branch 'rs/avoid-overflow-in-midpoint-computation'
Code clean-up to avoid signed integer overlaps during binary search. * rs/avoid-overflow-in-midpoint-computation: cleanup: fix possible overflow errors in binary search, part 2
Diffstat (limited to 'builtin')
-rw-r--r--builtin/ls-files.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 7f83c9a..670e8fb 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -373,7 +373,7 @@ static void prune_index(struct index_state *istate,
first = pos;
last = istate->cache_nr;
while (last > first) {
- int next = (last + first) >> 1;
+ int next = first + ((last - first) >> 1);
const struct cache_entry *ce = istate->cache[next];
if (!strncmp(ce->name, prefix, prefixlen)) {
first = next+1;