diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java index 31dac6a468..3676c3e2ed 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java +++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java @@ -223,7 +223,7 @@ public class POIXMLProperties { throw new POIXMLException(e); } } - if(extPart != null){ + if(extPart != null && ext != null && ext.props != null){ try (OutputStream out = extPart.getOutputStream()) { if (extPart.getSize() > 0) { extPart.clear(); @@ -231,7 +231,7 @@ public class POIXMLProperties { ext.props.save(out, DEFAULT_XML_OPTIONS); } } - if(custPart != null){ + if(custPart != null && cust != null && cust.props != null){ try (OutputStream out = custPart.getOutputStream()) { cust.props.save(out, DEFAULT_XML_OPTIONS); }