]> source.dussan.org Git - poi.git/commitdiff
Bug 64667.xlsx prevent NPE loading styles table
authorTim Allison <tallison@apache.org>
Thu, 13 Aug 2020 18:21:28 +0000 (18:21 +0000)
committerTim Allison <tallison@apache.org>
Thu, 13 Aug 2020 18:21:28 +0000 (18:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1880834 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/64667.xlsx [new file with mode: 0644]

index 2c89c2fae348aa99061a2e229650a050e4b4bd95..bfc24db6d0a150a30d2b3c0e08fee50afc1a0db1 100644 (file)
@@ -239,7 +239,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
             if(styleDxfs != null) dxfs.addAll(Arrays.asList(styleDxfs.getDxfArray()));
 
             CTTableStyles ctTableStyles = styleSheet.getTableStyles();
-            if (ctTableStyles != null) {
+            if (ctTableStyles != null && styleDxfs != null) {
                 int idx = 0;
                 for (CTTableStyle style : ctTableStyles.getTableStyleArray()) {
                     tableStyles.put(style.getName(), new XSSFTableStyle(idx, styleDxfs, style, indexedColors));
index b456d91aa64c816b6cf1679356dd504038288b28..22cf3f3a7af769fc55ba6b5f960c56b10f424a4f 100644 (file)
@@ -3560,4 +3560,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
             Assert.assertEquals("", aCell.getStringCellValue());
         }
     }
+
+    @Test
+    public void testBug64667() throws IOException {
+        //test that an NPE isn't thrown on opening
+        try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("64667.xlsx")) {
+            int activeSheet = wb.getActiveSheetIndex();
+        }
+    }
 }
diff --git a/test-data/spreadsheet/64667.xlsx b/test-data/spreadsheet/64667.xlsx
new file mode 100644 (file)
index 0000000..0541985
Binary files /dev/null and b/test-data/spreadsheet/64667.xlsx differ