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 41139] - Constructing HSSFWorkbook is failed,threw ArrayIndexOutOfBoundsException for creating UnknownRecord
Date Tue, 03 Apr 2007 21:00:17 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=41139>.
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=41139





------- Additional Comments From steveknoll@yahoo.com  2007-04-03 14:00 -------
I have run into the same bug (UnknownRecord throwing an
ArrayIndexOutOfBoundsException), and here is a possible solution
Change the 3rd constructor to read:
    public UnknownRecord( short id, short size, byte[] data, int offset )
    {
        sid     = id;

        // ObjRecord's fillFields was getting an obviously wrong subRecordSize,
        // which it passes to SubRecord.createSubRecord, which passes the value
        // here as "size".
        //
        // Instead of allowing an ArrayIndexOutOfBoundsException 
        //   to happen, let's change the size if appropriate.
        if ( size > (data.length - offset) ) {
          size = (short)(data.length - offset);
        }

        thedata = new byte[size];

        System.arraycopy(data, offset, thedata, 0, size);
    }
It could be argued that this is just patching the real problem; the real
problem is that we have bogus length/size for some Unknown record type
in Excel.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message