diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-07-29 12:38:21 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-29 12:38:21 -0700 |
commit | 0324b6f035a19f0098c321a7e6e17c04e9405be2 (patch) | |
tree | 40c48dc63c49002a009de35657f04cd3d5db64b2 /diffcore-rename.c | |
parent | 0100103d8e055891e820f78038ee40f2e8913854 (diff) | |
parent | 568a05c5ecb8e3a01fcb90d0f81857f49ef2add8 (diff) |
Merge branch 'rs/avoid-overflow-in-midpoint-computation' into maint
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 'diffcore-rename.c')
-rw-r--r-- | diffcore-rename.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c index 07bd34b631..6af92d5eba 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -23,7 +23,7 @@ static int find_rename_dst(struct diff_filespec *two) first = 0; last = rename_dst_nr; while (last > first) { - int next = (last + first) >> 1; + int next = first + ((last - first) >> 1); struct diff_rename_dst *dst = &(rename_dst[next]); int cmp = strcmp(two->path, dst->two->path); if (!cmp) @@ -83,7 +83,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p) first = 0; last = rename_src_nr; while (last > first) { - int next = (last + first) >> 1; + int next = first + ((last - first) >> 1); struct diff_rename_src *src = &(rename_src[next]); int cmp = strcmp(one->path, src->p->one->path); if (!cmp) |