Re: [PATCH JGIT] Computation of average could overflow
"Sohn, Matthias" <matthias.sohn@sap.com> wrote:
Show 7 quoted lines
> The code computes the average of two integers using either division or
> signed right shift, and then uses the result as the
> index of an array. If the values being averaged are very large, this can
> overflow (resulting in the computation of a negative
> average). Assuming that the result is intended to be nonnegative, you
> can use an unsigned right shift instead. In other
> words, rather that using (low+high)/2, use (low+high) >>> 1
Thanks, applied. But your patch was line wrapped. I had to unwrap
it by hand. Please try to configure your MUA not to line wrap
patches when it sends them. :-|
> .../src/org/spearce/jgit/dircache/DirCache.java | 2 +-
> .../src/org/spearce/jgit/lib/Tree.java | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
--
Shawn.