From ab2dc71a955d72faae3a0cd8df2ca89c1eaf9015 Mon Sep 17 00:00:00 2001 From: Tim Allison Date: Thu, 13 Aug 2020 18:21:28 +0000 Subject: [PATCH] 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 --- .../org/apache/poi/xssf/model/StylesTable.java | 2 +- .../apache/poi/xssf/usermodel/TestXSSFBugs.java | 8 ++++++++ test-data/spreadsheet/64667.xlsx | Bin 0 -> 8235 bytes 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test-data/spreadsheet/64667.xlsx 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(); + } + } } diff --git a/test-data/spreadsheet/64667.xlsx b/test-data/spreadsheet/64667.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..0541985d11ae32e07c8b9d89291a514be8b5848a GIT binary patch literal 8235 zcmbVx1z4NwvUTuaMO)m1wG@|9+=>NvZIKjrFD`}R4#g?%?!}9{dx7FkDbg1GN%!Gw z&i?ngxBE_>BwxNHD{p4a%sby2d1*L!TmaN$jL;Q+9sKJ789)v&v@(#lwX(KjQc*?+ zAhFtTycE5?L!TX-Q2{XUTW|otuLt>GFhBtC_RAFiMtOSsHs*a8J!@-5XAARRXd{V( z*oJ?PmZB(RInRvQh}S~~zi1%!LIKymgWOtiZG;?gCCeyIQ$v(4YS|M0W9gxkKcv1l zpLc)YLBJ>K{v`L!3R3L33YCU;gE=*lY%B=fWClmyy#6^KX7b?eFop`fBsz7 ze`Tv~XWLU|_m#ifj|M)`Go^KlkRd`DH-I}zAkcc4<0kE z6We~DHAXVyR10+kX7l1KxC8hGEHf>HRnDq*+TVpGU?zai5wS+%k!5>Jepfj>7^@%cSPo z)2N+0Oy|$%=TsjYzJ7E0vp}8ER(DnHnT^QGF|E-LJb7s(;77946@M520LtXwb8H9; z0AStc*ucsb@;fAlMlDHyV#f4ZLbwTt`p&t%Au2NO-Iq!Xw4`f(yH%3O#n98`$t8bgi`i^@F*7t zcNJ^tdYi8+AqaS&AE1J&+=Vz}JfCcQ*Jij*w@1h%(L}4bs7E_BGpyIWHD0uS3;GD& z$dB+X-{zBq@^~-fo64vAcDux_zU1^$y4DwpCy12t_kA0@MbACr%7j#A zl30}BXq+t2eb~P_eUP6&v0w2ly#O=W7Ks60t(dP4HXOG5baEg7qJ8?p$NAaGgbQ!` zRc6>JdDJsBzA%rzMj5g+RaE8b3$R^ORBzD2$gDdrnZ>TasX_J*(bYJ2rr*f6`5G^> zCO!WJF3UL_lo6@9jbOH0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