]> source.dussan.org Git - aspectj.git/commitdiff
added a range check to avoid ArrayIndexOutOfBounds
authorjhugunin <jhugunin>
Wed, 5 Mar 2003 19:33:20 +0000 (19:33 +0000)
committerjhugunin <jhugunin>
Wed, 5 Mar 2003 19:33:20 +0000 (19:33 +0000)
-- this bug was found by the unit tests and should have been fixed when
   this method was added

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceLocation.java

index d245cb90f52eec1f0f0b25dfe6a96edd24651cdf..3f917023778e6e0accbf25857f7bea92b6d701f7 100644 (file)
@@ -57,8 +57,9 @@ public class EclipseSourceLocation implements ISourceLocation {
        public int getColumn() {
         if (-1 == column) {
             int lineNumber = getLine();
-            if (0 < lineNumber) {
-                int lineStart = result.lineSeparatorPositions[getLine()];
+            // JJH added check that lineNumber is in legal range to avoid exceptions
+            if (0 < lineNumber && lineNumber < result.lineSeparatorPositions.length) {
+                int lineStart = result.lineSeparatorPositions[lineNumber];
                 int col = startPos - lineStart; // 1-based
                 if (0 <= col) { 
                     column = col;