diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java index f9bdfb7ad8..177a570882 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java @@ -127,8 +127,11 @@ public class XWPFFootnotes extends XWPFAbstractFootnotesEndnotes { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes")); PackagePart part = getPackagePart(); - try (OutputStream out = part.getOutputStream()) { - ctFootnotes.save(out, xmlOptions); + + if (ctFootnotes != null) { + try (OutputStream out = part.getOutputStream()) { + ctFootnotes.save(out, xmlOptions); + } } } diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-5166796835258368.docx b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-5166796835258368.docx new file mode 100644 index 0000000000..08e62e49e2 Binary files /dev/null and b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-5166796835258368.docx differ