aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Allison <tallison@apache.org>2020-08-13 18:21:28 +0000
committerTim Allison <tallison@apache.org>2020-08-13 18:21:28 +0000
commitab2dc71a955d72faae3a0cd8df2ca89c1eaf9015 (patch)
tree1d9e64b4ac761701c3c7bc6abd7ab81e92de3b2b /src
parent252a4eccc949445bb20c5dfc4667bc0f823f40f6 (diff)
downloadpoi-ab2dc71a955d72faae3a0cd8df2ca89c1eaf9015.tar.gz
poi-ab2dc71a955d72faae3a0cd8df2ca89c1eaf9015.zip
Bug 64667.xlsx prevent NPE loading styles table
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1880834 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
index 2c89c2fae3..bfc24db6d0 100644
--- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
+++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
@@ -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));
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index b456d91aa6..22cf3f3a7a 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -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();
+ }
+ }
}