Skip to content

Commit

Permalink
Prevent ArrayIndexOutOfBoundsException.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Aquino committed May 23, 2015
1 parent 87d58aa commit 3544925
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ public void loadRevision() throws Exception {
int position = (int)Math.round(((float)leftViewport.getViewPosition().y / leftViewport.getViewSize().height) * currentDiff.getLeftLineNumbers().size());
List lineNumbers = revisionDelta == -1 ? currentDiff.getLeftLineNumbers() : currentDiff.getRightLineNumbers();
for (int i = position; i >= 0; i--) {
if (i >= lineNumbers.size()) {
// I saw an ArrayIndexOutOfBoundsException and I suspect it was here.
// Adding this check just in case.
continue;
}
if (lineNumbers.get(i).toString().length() > 0) {
lineNumberToPreserve = lineNumbers.get(i).toString();
break;
Expand Down

0 comments on commit 3544925

Please sign in to comment.