Bug 41026 - [PATCH] ArrayIndexOutOfBoundsException in ValueRecordsAggregate.rowHasCells
Summary: [PATCH] ArrayIndexOutOfBoundsException in ValueRecordsAggregate.rowHasCells
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: All other
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-11-23 05:45 UTC by Julien Aymé
Modified: 2007-03-05 02:38 UTC (History)
0 users



Attachments
Patch for the class org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate (511 bytes, patch)
2006-11-23 05:48 UTC, Julien Aymé
Details | Diff
Patch for the class org.apache.poi.hssf.record.aggregates.TestValueRecordsAggregate (494 bytes, patch)
2006-11-23 05:50 UTC, Julien Aymé
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>