diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-07-09 15:25:37 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-09 15:25:38 -0700 |
commit | 891c1c280f070998428868d9a175c89341f8c982 (patch) | |
tree | 8678828ba73e9a971237cbcfb58426789000c143 /read-cache.c | |
parent | 1b074e15d0f976be2bc14f9528874a841c055213 (diff) | |
parent | 568a05c5ecb8e3a01fcb90d0f81857f49ef2add8 (diff) | |
download | git-891c1c280f070998428868d9a175c89341f8c982.tar.gz |
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 'read-cache.c')
-rw-r--r-- | read-cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c index 4dd22f4f6e..c701f7f8b8 100644 --- a/read-cache.c +++ b/read-cache.c @@ -549,7 +549,7 @@ static int index_name_stage_pos(const struct index_state *istate, const char *na first = 0; last = istate->cache_nr; while (last > first) { - int next = (last + first) >> 1; + int next = first + ((last - first) >> 1); struct cache_entry *ce = istate->cache[next]; int cmp = cache_name_stage_compare(name, namelen, stage, ce->name, ce_namelen(ce), ce_stage(ce)); if (!cmp) |