Bug 51143 - "Buffer overrun" Exception with named area with accent AND comment
Summary: "Buffer overrun" Exception with named area with accent AND comment
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2011-05-03 09:28 UTC by F. Degrigny
Modified: 2011-05-04 03:11 UTC (History)
1 user (show)

files that reproduce the bug (8.29 KB, application/x-zip-compressed)
2011-05-03 09:28 UTC, F. Degrigny

Note You need to log in before you can comment on or make changes to this bug.
Description F. Degrigny 2011-05-03 09:28:42 UTC
Created attachment 26949 [details]
files that reproduce the bug

The following exception occurs when a tryinf to resave workbook containing a name area with characters with accent (like french ones) in its name and a comment OR no accent in the name but one in the comment.
(the following case : characters with accent in the name and no comment, works well)

Exception in thread "main" java.lang.RuntimeException: Buffer overrun
	at org.apache.poi.util.LittleEndianByteArrayOutputStream.checkPosition(LittleEndianByteArrayOutputStream.java:51)
	at org.apache.poi.util.LittleEndianByteArrayOutputStream.write(LittleEndianByteArrayOutputStream.java:88)
	at org.apache.poi.hssf.record.NameCommentRecord.serialize(NameCommentRecord.java:68)
	at org.apache.poi.hssf.record.StandardRecord.serialize(StandardRecord.java:41)
	at org.apache.poi.hssf.model.InternalWorkbook.serialize(InternalWorkbook.java:1036)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1246)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1149)

Java code : just open the test file and resave it with POI.
Comment 1 Nick Burch 2011-05-04 03:11:35 UTC
The write logic was incorrect for non US-ASCII strings (read logic was fine). Fixed in r1099313.