Bug 41026

Summary: [PATCH] ArrayIndexOutOfBoundsException in ValueRecordsAggregate.rowHasCells
Product: POI Reporter: Julien Aymé <julien.ayme>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major Keywords: PatchAvailable
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: All   
OS: other   
Attachments: Patch for the class org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate
Patch for the class org.apache.poi.hssf.record.aggregates.TestValueRecordsAggregate

Description Julien Aymé 2006-11-23 05:45:27 UTC
Calling the method ValueRecordsAgregate.rowHasCells(int) with the parameter
equals to the length of the records throws an ArrayIndexOutOfBoundsException.
This happened when I called the method HSSFWorkbook.write(OutputStream):

The stacktrace:
java.lang.ArrayIndexOutOfBoundsException: 30
	at
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.rowHasCells(ValueRecordsAggregate.java:195)
	at org.apache.poi.hssf.model.Sheet.getSize(Sheet.java:2112)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:920)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:875)

I join two patches:
One for ValueRecordsAggregate, and one for TestValueRecordsAggregate.
Comment 1 Julien Aymé 2006-11-23 05:48:55 UTC
Created attachment 19166 [details]
Patch for the class org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate

A little bug: just an '>=' instead of '>' and its all done.
Comment 2 Julien Aymé 2006-11-23 05:50:31 UTC
Created attachment 19167 [details]
Patch for the class org.apache.poi.hssf.record.aggregates.TestValueRecordsAggregate

Adds a test corresponding to the bug.
Comment 3 Rajneesh Gupta 2006-12-03 04:12:58 UTC
(In reply to comment #0)
> Calling the method ValueRecordsAgregate.rowHasCells(int) with the parameter
> equals to the length of the records throws an ArrayIndexOutOfBoundsException.
> This happened when I called the method HSSFWorkbook.write(OutputStream):
> 
> The stacktrace:
> java.lang.ArrayIndexOutOfBoundsException: 30
> 	at
>
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.rowHasCells(ValueRecordsAggregate.java:195)
> 	at org.apache.poi.hssf.model.Sheet.getSize(Sheet.java:2112)
> 	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:920)
> 	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:875)
> 
> I join two patches:
> One for ValueRecordsAggregate, and one for TestValueRecordsAggregate.

Modifying the source of
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.rowHasCells method
dosent work either. [    if (row >= records.length)    ]

Same exception is thrown again. 
Comment 4 Avik Sengupta 2007-01-11 04:04:37 UTC
Can someone please put in a testcase that triggers this bug? Its quite 
difficult to fix otherwise. Thanks. 
Comment 5 Avik Sengupta 2007-01-16 07:51:07 UTC
The same expection is thrown now on reading the file attached to Bug 37684 .
Without a testcase here, cannot confirm if the bug is the same... the symptoms
seem similar. The attached patch does not fix this. 
Comment 6 Julien Aymé 2007-03-05 02:38:19 UTC
This has been fixed with the commit 
<a href="http://svn.apache.org/viewvc?view=rev&revision=513609">#513609</a>