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=31821>.
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=31821

EscherArrayProperty class throws ArayIndexoutofbounds exception.

           Summary: EscherArrayProperty class throws ArayIndexoutofbounds
                    exception.
           Product: POI
           Version: 2.5
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: HSSF
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I am getting a exception when i am trying to biff view xls  file.

java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at org.apache.poi.ddf.EscherArrayProperty.getElement
(EscherArrayProperty
.java:111)
        at org.apache.poi.ddf.EscherArrayProperty.toString
(EscherArrayProperty.j
ava:146)
        at org.apache.poi.ddf.EscherOptRecord.toString
(EscherOptRecord.java:138)

        at org.apache.poi.ddf.EscherContainerRecord.toString
(EscherContainerReco
rd.java:158)
        at org.apache.poi.hssf.record.AbstractEscherHolderRecord.toString
(Abstra
ctEscherHolderRecord.java:126)
        at org.apache.poi.hssf.dev.BiffViewer.dumpNormal(BiffViewer.java:148)
        at org.apache.poi.hssf.dev.BiffViewer.access$1(BiffViewer.java:144)
        at org.apache.poi.hssf.dev.BiffViewer$RecordDetails.dump
(BiffViewer.java
:700)
        at org.apache.poi.hssf.dev.BiffViewer.createRecords
(BiffViewer.java:120)

        at org.apache.poi.hssf.dev.BiffViewer.run(BiffViewer.java:73)
        at org.apache.poi.hssf.dev.BiffViewer.main(BiffViewer.java:652)



I just debugged a little  and found a strange thing

Here is the modified code i used to debug

    public byte[] getElement( int index )
    {
        int actualSize = getActualSizeOfElements(getSizeOfElements());
        byte[] result = new byte[actualSize];
       try {
                        System.arraycopy(complexData, FIXED_SIZE + index * 
actualSize, result, 0, result.length );
                        //System.arraycopy(complexData, 0, result, 0, 
result.length );
        } catch (Exception exception) {
                System.out.println("================");
                System.out.println("src array total length 
= "+complexData.length);
                        //System.out.println("src position = "+FIXED_SIZE + 
index * actualSize);
                        System.out.println("FIXED_SIZE  "+FIXED_SIZE);
                        System.out.println("index  "+index);
                        System.out.println("actualSize  "+actualSize);
                        System.out.println("dest array len = "+result.length);
                        
                        System.out.println("length = "+result.length);
                        
                        System.out.println("=================");
        }

The results are surprising..
here are they

src array total length = 6
FIXED_SIZE  6
index  7
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  8
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  9
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  10
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  11
actualSize  1290
dest array len = 1290
length = 1290
=================
================
src array total length = 6
FIXED_SIZE  6
index  12
actualSize  1290
dest array len = 1290
length = 1290
=================

So is the logic 

System.arraycopy(complexData, FIXED_SIZE + index * actualSize, result, 0, 
result.length );
 correct??

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to