poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30008] New: - ArrayIndexOutOfBounds exception in UnknownRecord.java and Nullpointer Exception in HSSFSheet.java
Date Fri, 09 Jul 2004 18:33:48 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30008>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30008

ArrayIndexOutOfBounds exception in UnknownRecord.java and Nullpointer Exception in HSSFSheet.java

           Summary: ArrayIndexOutOfBounds exception in UnknownRecord.java
                    and Nullpointer Exception in HSSFSheet.java
           Product: POI
           Version: 2.5
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: christian.schuhegger@cern.ch


in the following patch you can see that i added a check for an array index out
of bounds and a check for a null pointer. 

it is quite possible that the two methods i fixed state in their pre-conditions
that something like that should not happen, but then the bug is somewhere else
because these pre-conditions were violated.

Index: src/java/org/apache/poi/hssf/record/UnknownRecord.java
===================================================================
RCS file:
/home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/UnknownRecord.java,v
retrieving revision 1.9
diff -c -r1.9 UnknownRecord.java
*** src/java/org/apache/poi/hssf/record/UnknownRecord.java	9 Apr 2004 13:05:20
-0000	1.9
--- src/java/org/apache/poi/hssf/record/UnknownRecord.java	30 Jun 2004 17:31:44
-0000
***************
*** 62,68 ****
      {
          sid     = id;
          thedata = new byte[size];
!         System.arraycopy(data, offset, thedata, 0, size);
      }   
  
      /**
--- 62,69 ----
      {
          sid     = id;
          thedata = new byte[size];
!         int len = Math.min(size, data.length - offset);
!         System.arraycopy(data, offset, thedata, 0, len);
      }   
  
      /**
Index: src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
===================================================================
RCS file:
/home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java,v
retrieving revision 1.27
diff -c -r1.27 HSSFSheet.java
*** src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java	9 Apr 2004 13:05:24
-0000	1.27
--- src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java	30 Jun 2004 17:31:44 -0000
***************
*** 308,313 ****
--- 308,315 ----
  
      public HSSFRow getRow(int rownum)
      {
+         if(null == this.sheet.getRow(rownum))
+             return null;
          HSSFRow retval = new HSSFRow(book, sheet, this.sheet.getRow(rownum));
  
          return retval;

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


Mime
View raw message