From: Dominik Stadler Date: Sun, 14 Jul 2024 11:26:56 +0000 (+0000) Subject: Bug 66425: Avoid exceptions found via poi-fuzz X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a0421651334ce1344b6085274ab4a7284a266bf5;p=poi.git Bug 66425: Avoid exceptions found via poi-fuzz 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 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFMasters.java b/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFMasters.java index 7bc97dd79f..315c5921b4 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFMasters.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XDGFMasters.java @@ -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 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 index 0000000000..b08f248233 Binary files /dev/null and b/test-data/diagram/clusterfuzz-testcase-minimized-POIVisioFuzzer-5492358185353216.vsdx differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 7f0fb70430..efe00e3845 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ