MultiPackIndexV1: Calculate memsize with long Errorprone pointed out that adding with int and casting to long at the end could overflow. Mark one of the operands as long to do the addition directly as long and avoid the overflow risk. Change-Id: I12449af90c84044a04e6dbd0978ff48d0ea33674
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/midx/MultiPackIndexV1.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/midx/MultiPackIndexV1.java index 63d77cd..bb122c7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/midx/MultiPackIndexV1.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/midx/MultiPackIndexV1.java
@@ -146,7 +146,7 @@ void getObjectOffset(int position, PackOffset result) { } long getMemorySize() { - return byteArrayLengh(offsets) + byteArrayLengh(largeOffsets); + return (long)byteArrayLengh(offsets) + byteArrayLengh(largeOffsets); } } @@ -227,7 +227,7 @@ int findMultiPackIndexPosition(AnyObjectId id) { } long getMemorySize() { - return 4 + byteArrayLengh(oidLookup) + (FANOUT * 4); + return 4L + byteArrayLengh(oidLookup) + (FANOUT * 4); } } }