summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-09-15 11:48:05 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2024-02-13 13:56:25 +0100
commit99333e75bc002711fe4f2ddcaf5740e20c3f7e92 (patch)
tree0381fd4bfadad8aecbb81eb10f14d80ffe79ddbd /org.eclipse.jgit
parentaf5d4d37ae3ef6612a7530112d5ff15f6e3f5d8d (diff)
downloadjgit-99333e75bc002711fe4f2ddcaf5740e20c3f7e92.tar.gz
jgit-99333e75bc002711fe4f2ddcaf5740e20c3f7e92.zip
[errorprone] Fix wrong comparison which always evaluated to false
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java:59: error: [ComparisonOutOfRange] ints may have a value in the range -2147483648 to 2147483647; therefore, this comparison to Integer.MAX_VALUE will always evaluate to false if (table[k] > Integer.MAX_VALUE) { ^ See https://errorprone.info/bugpattern/ComparisonOutOfRange We need to check if variable `uint` of type `long` exceeds the maximum possible int value before casting it to `int` below. This was introduced in Ib5c0d6678cb242870a0f5841bd413ad3885e95f6 Change-Id: I675d594f523084be4c1678328cc343065e32d998 (cherry picked from commit 916200e278ebeaa2602b5dc23143c8eedf11858b)
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java
index 22b4011f9f..a15602a168 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/GraphObjectIndex.java
@@ -56,7 +56,7 @@ class GraphObjectIndex {
long uint32;
for (int k = 0; k < table.length; k++) {
uint32 = NB.decodeUInt32(oidFanout, k * 4);
- if (table[k] > Integer.MAX_VALUE) {
+ if (uint32 > Integer.MAX_VALUE) {
throw new CommitGraphFormatException(
JGitText.get().commitGraphFileIsTooLargeForJgit);
}