Bug 19862

Summary: [PATCH] Runtime Exception in NameRecord.java
Product: POI Reporter: John Lloyd <lloydj>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: other   
Attachments: This file causes the exception when processed by HSSFWorkbook
Patch file made from 1.10.0 developer build

Description John Lloyd 2003-05-12 18:07:39 UTC
While processing an Excel file (available upon request) with HSSF, I got a run-
time exception in the method NameRecord.fillFields(). I looked at the code and 
found a bug in line 658 of that method in the file NameRecord.java in version 
1.10.0. The code should be adding the length of the previous variable length 
field to find the start of the current field. Instead it is adding the length 
of the current field. I changed the line as below to solve the problem. How do 
I get this change into the HSSF base?

          //int start_of_description_text   = start_of_custom_menu_text + 
field_8_length_description_text;
	    int start_of_description_text   = start_of_custom_menu_text + 
field_7_length_custom_menu;

The exception occurs with some macros as below with the 1.10.0 developer 
release. 

java.lang.reflect.InvocationTargetException:
java.lang.StringIndexOutOfBoundsException: String index out of range: 63
        at java.lang.String.<init>(Unknown Source)
        at java.lang.String.<init>(Unknown Source)
        at
org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:633)

        at org.apache.poi.hssf.record.Record.fillFields(Record.java:143)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:105)
        at
org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:121)
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:254)
        at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:192)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:187)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:234)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:215)
        at
com.ibm.wps.odc.convert.sheet.ExcelReader.read(ExcelReader.java:118)
Comment 1 John Lloyd 2003-05-12 18:11:04 UTC
Created attachment 6327 [details]
This file causes the exception when processed by HSSFWorkbook
Comment 2 John Lloyd 2003-05-12 18:12:35 UTC
Created attachment 6328 [details]
Patch file made from 1.10.0 developer build
Comment 3 Danny Mui 2003-05-17 18:36:50 UTC
Committed 05/17/2003.

Thanks for the contribution, please verify.  Would highly appreciate test cases
in the future to prevent this bug from resurfacing and speed patching along.

Thanks again!