Fix for readCompressedUnicode not moaning about length=0, from bug #44643

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@639242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2008-03-20 11:02:39 +00:00
parent b57f30921b
commit f5b67d0e52
3 changed files with 18 additions and 1 deletions

View File

@ -266,6 +266,9 @@ public class RecordInputStream extends InputStream
}
public String readCompressedUnicode(int length) {
if(length == 0) {
return "";
}
if ((length < 0) || ((remaining() < length) && !isContinueNext())) {
throw new IllegalArgumentException("Illegal length " + length);
}

Binary file not shown.

View File

@ -1204,6 +1204,20 @@ extends TestCase {
assertEquals(2, wb.getNumberOfSheets());
}
/**
* Used to give problems due to trying to read a zero
* length string, but that's now properly handled
*/
public void test44643() throws Exception {
FileInputStream in = new FileInputStream(new File(cwd, "44643.xls"));
// Used to blow up with an IllegalArgumentException
HSSFWorkbook wb = new HSSFWorkbook(in);
in.close();
assertEquals(1, wb.getNumberOfSheets());
}
}