Bug 42799

Summary: Array out of bound exception in ListTables public ListLevel getLevel(int listID, int level)
Product: POI Reporter: Robert Pastor <robert.pastor>
Component: HWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Attachments: This "corrupted" WORD 2000 file leads to an "array out of bound" exception

Description Robert Pastor 2007-07-03 02:06:46 UTC
package org.apache.poi.hwpf.model;
public class ListTables
When the "level" index is greater to the lst.numLevels() we got an array out of 
bound exception:
Proposed change is :
public ListLevel getLevel(int listID, int level)
  {
    ListData lst = (ListData)_listMap.get(new Integer(listID));
    if (level < lst.numLevels()) {
    	ListLevel lvl = lst.getLevels()[level];
    	return lvl;
    }
    else {
    	return null;
    }
  }
Comment 1 Nick Burch 2007-07-03 06:52:11 UTC
Do you have a sample file that shows up this problem, that you could attach to
the bug?
Comment 2 Robert Pastor 2007-07-04 01:57:15 UTC
Created attachment 20445 [details]
This "corrupted" WORD 2000 file leads to an "array out of bound" exception

Trying to sort out where the problem would be in the MS WORD input file, I
discovered that the WORD document was stated as "corrupted" by MS WORD when
opening it.
I understand that the proposed solution does not correct the root cause of the
problem, but only tries to avoid an exception which does not retrieve the kind
of data I wanted to extract from the MS WORD file.
Comment 3 Nick Burch 2007-12-04 04:33:25 UTC
Proposed patch applied