]> source.dussan.org Git - poi.git/commitdiff
Bug 66425: Avoid exceptions found via poi-fuzz
authorDominik Stadler <centic@apache.org>
Wed, 17 Apr 2024 18:15:38 +0000 (18:15 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 17 Apr 2024 18:15:38 +0000 (18:15 +0000)
Prevent a NullPointerException

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66386

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917069 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
test-data/spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-4828727001088000.xlsx [new file with mode: 0644]
test-data/spreadsheet/stress.xls

index 0ede2c2c5fbe82dc076c3c4c7ddea0cd5150be36..18c69b616b3cc824345938c300ed2666a1c745b8 100644 (file)
@@ -63,9 +63,10 @@ public final class XSSFGraphicFrame extends XSSFShape {
             for (int i = 0; i < nodes.getLength(); i++) {
                 final Node node = nodes.item(i);
                 // if the frame references a chart, associate the chart with this instance
-                if (node.getNodeName().equals("c:chart")) {
+                Node namedItem = node.getAttributes().getNamedItem("r:id");
+                if (node.getNodeName().equals("c:chart") && namedItem != null) {
                     // this better succeed or the document is invalid
-                    POIXMLDocumentPart relation = drawing.getRelationById(node.getAttributes().getNamedItem("r:id").getNodeValue());
+                    POIXMLDocumentPart relation = drawing.getRelationById(namedItem.getNodeValue());
                     // Do XWPF charts need similar treatment?
                     if (relation instanceof XSSFChart) {
                         ((XSSFChart) relation).setGraphicFrame(this);
diff --git a/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-4828727001088000.xlsx b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-4828727001088000.xlsx
new file mode 100644 (file)
index 0000000..76b1105
Binary files /dev/null and b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIXSSFFuzzer-4828727001088000.xlsx differ
index f32cb34e1611cd30c6dc4e7bf07c488a82604dec..98ce7f52d696d9a3b2170da68b9f893a409b4c8d 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ