]> source.dussan.org Git - poi.git/commitdiff
Bug 66425: Avoid exceptions found via poi-fuzz
authorDominik Stadler <centic@apache.org>
Sun, 14 Jul 2024 11:26:56 +0000 (11:26 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 14 Jul 2024 11:26:56 +0000 (11:26 +0000)
Prevent a NullPointerException

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

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

poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFMasters.java
test-data/diagram/clusterfuzz-testcase-minimized-POIVisioFuzzer-5492358185353216.vsdx [new file with mode: 0644]
test-data/spreadsheet/stress.xls

index 7bc97dd79fa9ad319fa5e4acd049e1f941a028d7..315c5921b4dab1f5b76ab5911187d614b26b501b 100644 (file)
@@ -27,6 +27,8 @@ import java.util.Map;
 import com.microsoft.schemas.office.visio.x2012.main.MasterType;
 import com.microsoft.schemas.office.visio.x2012.main.MastersDocument;
 import com.microsoft.schemas.office.visio.x2012.main.MastersType;
+import com.microsoft.schemas.office.visio.x2012.main.RelType;
+
 import org.apache.poi.ooxml.POIXMLDocumentPart;
 import org.apache.poi.ooxml.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
@@ -68,7 +70,10 @@ public class XDGFMasters extends XDGFXMLDocumentPart {
 
             Map<String, MasterType> masterSettings = new HashMap<>();
             for (MasterType master: _mastersObject.getMasterArray()) {
-                masterSettings.put(master.getRel().getId(), master);
+                RelType rel = master.getRel();
+                if (rel != null) {
+                    masterSettings.put(rel.getId(), master);
+                }
             }
 
             // create the masters
diff --git a/test-data/diagram/clusterfuzz-testcase-minimized-POIVisioFuzzer-5492358185353216.vsdx b/test-data/diagram/clusterfuzz-testcase-minimized-POIVisioFuzzer-5492358185353216.vsdx
new file mode 100644 (file)
index 0000000..b08f248
Binary files /dev/null and b/test-data/diagram/clusterfuzz-testcase-minimized-POIVisioFuzzer-5492358185353216.vsdx differ
index 7f0fb70430ae9112cbaa4e45583e3639d8b9007e..efe00e384546694647236a6ed9200e79109fb71f 100644 (file)
Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ