diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/poi/hpsf/CodePageString.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/hpsf/CodePageString.java b/src/java/org/apache/poi/hpsf/CodePageString.java index eaaa11e51b..b94cb67c13 100644 --- a/src/java/org/apache/poi/hpsf/CodePageString.java +++ b/src/java/org/apache/poi/hpsf/CodePageString.java @@ -42,7 +42,7 @@ class CodePageString offset += LittleEndian.INT_SIZE; _value = LittleEndian.getByteArray( data, offset, size ); - if ( _value[size - 1] != 0 ) { + if ( size != 0 && _value[size - 1] != 0 ) { // TODO Some files, such as TestVisioWithCodepage.vsd, are currently // triggering this for values that don't look like codepages // See Bug #52258 for details diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java b/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java index 05c8d8b99f..ff9ba878a5 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java @@ -138,4 +138,27 @@ public final class TestHPSFBugs extends TestCase { assertEquals("", si.getAuthor()); assertEquals("Cour de Justice", dsi.getCompany()); } + + /** + * CodePage Strings can be zero length + */ + public void test56138() throws Exception { + DocumentInputStream dis; + POIFSFileSystem fs = + new POIFSFileSystem(_samples.openResourceAsStream("TestZeroLengthCodePage.mpp")); + + dis = fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME); + SummaryInformation si = (SummaryInformation)PropertySetFactory.create(dis); + + dis = fs.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME); + DocumentSummaryInformation dsi = (DocumentSummaryInformation)PropertySetFactory.create(dis); + + // Test + assertEquals("MSProject", si.getApplicationName()); + assertEquals("project1", si.getTitle()); + assertEquals("Jon Iles", si.getAuthor()); + + assertEquals("", dsi.getCompany()); + assertEquals(2, dsi.getSectionCount()); + } } |