Bug 47958 - ArrayIndexOutOfBoundsException from PicturesTable.getAllPictures() during Escher tree walk
Summary: ArrayIndexOutOfBoundsException from PicturesTable.getAllPictures() during Esc...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.5-FINAL
Hardware: PC Windows NT
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 50936 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-07 20:27 UTC by Trejkaz (pen name)
Modified: 2011-10-30 00:35 UTC (History)
1 user (show)



Attachments
Sample file (664.00 KB, application/msword)
2009-10-07 20:27 UTC, Trejkaz (pen name)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trejkaz (pen name) 2009-10-07 20:27:42 UTC
Created attachment 24360 [details]
Sample file

Put the sample file somewhere, adjust this test to point to the correct file
location and run.

    @Test
    public void testPictureExtractionProblem() throws Exception
    {
        File file = new File("C:\\Data\\Test\\NUIQ021202.doc");
        POIFSFileSystem poifs;
        InputStream stream = new FileInputStream(file);
        try
        {
            poifs = new POIFSFileSystem(stream);
        }
        finally
        {
            stream.close();
        }

        HWPFDocument doc = new HWPFDocument(poifs);

        // Throws ArrayIndexOutOfBoundsException
        doc.getPicturesTable().getAllPictures();
    }

Gives the following error:

java.lang.ArrayIndexOutOfBoundsException: 50206
    at org.apache.poi.util.LittleEndian.getShort(LittleEndian.java:45)
    at
org.apache.poi.ddf.EscherRecord$EscherRecordHeader.readHeader(EscherRecord.java:250)
    at
org.apache.poi.ddf.DefaultEscherRecordFactory.createRecord(DefaultEscherRecordFactory.java:56)
    at
org.apache.poi.hwpf.model.PicturesTable.searchForPictures(PicturesTable.java:171)
    at
org.apache.poi.hwpf.model.PicturesTable.searchForPictures(PicturesTable.java:178)
    at
org.apache.poi.hwpf.model.PicturesTable.searchForPictures(PicturesTable.java:178)
    at
org.apache.poi.hwpf.model.PicturesTable.getAllPictures(PicturesTable.java:202)

There does appear to be a picture in the document but it's unknown to me
whether it's embedded directly or via an OLE2 container (what is known is that
there *is* one OLE2 container in the file.)
Comment 1 Yegor Kozlov 2011-06-24 08:25:01 UTC
Still have the problem in trunk.

Yegor
Comment 2 Sergey Vladimirov 2011-10-30 00:31:42 UTC
*** Bug 50936 has been marked as a duplicate of this bug. ***
Comment 3 Sergey Vladimirov 2011-10-30 00:35:11 UTC
I added workaround to skip pictures that can't be loaded and print an exception for those in logs. It turns out in example files we have more records than pictures present.

Done in revision 1195080