]> source.dussan.org Git - poi.git/commitdiff
fix amateur hour coding mistake tags/REL_3_0_RC1@516901
authorAndrew C. Oliver <acoliver@apache.org>
Fri, 2 Mar 2007 03:48:55 +0000 (03:48 +0000)
committerAndrew C. Oliver <acoliver@apache.org>
Fri, 2 Mar 2007 03:48:55 +0000 (03:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@513609 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java

index b5525987b1695e36adf48981b58c215cbd4b221d..80b932c51c866903bb1cab84bc813e1e18d436b5 100644 (file)
@@ -214,9 +214,9 @@ public class ValueRecordsAggregate
 
     /** Returns true if the row has cells attached to it */
     public boolean rowHasCells(int row) {
-       if (row > records.length)
-               return false;
-      CellValueRecordInterface[] rowCells=records[row];
+       if (row > records.length-1) //previously this said row > records.length which means if 
+               return false;  // if records.length == 60 and I pass "60" here I get array out of bounds
+      CellValueRecordInterface[] rowCells=records[row]; //because a 60 length array has the last index = 59
       if(rowCells==null) return false;
       for(int col=0;col<rowCells.length;col++) {
         if(rowCells[col]!=null) return true;
@@ -334,7 +334,8 @@ public class ValueRecordsAggregate
     private void findNext() {
       nextColumn++;
       for(;nextRow<=lastRow;nextRow++) {
-        CellValueRecordInterface[] rowCells=records[nextRow];
+                                           //previously this threw array out of bounds...
+        CellValueRecordInterface[] rowCells=(nextRow < records.length) ? records[nextRow] : null;
         if(rowCells==null) { // This row is empty
           nextColumn=0;
           continue;
@@ -347,4 +348,4 @@ public class ValueRecordsAggregate
     }
 
   }
-}
\ No newline at end of file
+}