summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2015-01-27 00:53:04 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2015-01-27 00:53:04 -0500
commit66cbf9255cef5a6c7f3c008fa9cb36c2bd8066a9 (patch)
tree5947025d9f69b558a4fcf5f316575a5f4640b8c1
parente463fdef1549b7a9a23440ff61851eecf106963e (diff)
parent786ad999cdd48a952ef6f270e3e76040259e6f67 (diff)
downloadjgit-66cbf9255cef5a6c7f3c008fa9cb36c2bd8066a9.tar.gz
jgit-66cbf9255cef5a6c7f3c008fa9cb36c2bd8066a9.zip
Merge "Fix integer overflow in DiffFormatter when context is set to large int"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
index a4b6ab1278..d339d6a65a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
@@ -737,10 +737,10 @@ public class DiffFormatter {
final int endIdx = findCombinedEnd(edits, curIdx);
final Edit endEdit = edits.get(endIdx);
- int aCur = Math.max(0, curEdit.getBeginA() - context);
- int bCur = Math.max(0, curEdit.getBeginB() - context);
- final int aEnd = Math.min(a.size(), endEdit.getEndA() + context);
- final int bEnd = Math.min(b.size(), endEdit.getEndB() + context);
+ int aCur = (int) Math.max(0, (long) curEdit.getBeginA() - context);
+ int bCur = (int) Math.max(0, (long) curEdit.getBeginB() - context);
+ final int aEnd = (int) Math.min(a.size(), (long) endEdit.getEndA() + context);
+ final int bEnd = (int) Math.min(b.size(), (long) endEdit.getEndB() + context);
writeHunkHeader(aCur, aEnd, bCur, bEnd);