neelmanisingh / java-diff-utils

Automatically exported from code.google.com/p/java-diff-utils
0 stars 0 forks source link

ArrayIndexOutOfBoundsException when both original and revision List is empty #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call DiffUtils.diff(new ArrayList<String>(), new ArrayList<String>())
2. java.lang.ArrayIndexOutOfBoundsException: 3
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
1.2

Please provide any additional information below.
Full stacktrace:
java.lang.ArrayIndexOutOfBoundsException: 3
    at difflib.myers.MyersDiff.buildPath(MyersDiff.java:140)
    at difflib.myers.MyersDiff.diff(MyersDiff.java:106)
    at difflib.myers.MyersDiff.diff(MyersDiff.java:94)
    at difflib.DiffUtils.diff(DiffUtils.java:58)
    at difflib.DiffUtils.diff(DiffUtils.java:46)

Original issue reported on code.google.com by xuantinh@gmail.com on 5 Oct 2010 at 5:08

GoogleCodeExporter commented 8 years ago
This code snippet caused the problem: with M=0 and N=0
// these are local constants
final int N = orig.length;
final int M = rev.length;

final int MAX = N + M + 1;
final int size = 1 + 2 * MAX;
final int middle = (size + 1) / 2;
final PathNode diagonal[] = new PathNode[size];

diagonal[middle + 1] = new Snake(0, -1, null); <--- die at this line :)

Original comment by xuantinh@gmail.com on 5 Oct 2010 at 5:11

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by dm.naume...@gmail.com on 15 Oct 2010 at 11:36

GoogleCodeExporter commented 8 years ago
Thanks, was fixed in the latest commits. I will update you when these changes 
will be released.

Original comment by dm.naume...@gmail.com on 15 Oct 2010 at 11:56