Bug 66425: Avoid exceptions found via poi-fuzz

Prevent a NullPointerException

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

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1917175 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2024-04-20 07:53:40 +00:00
parent 8c101982e0
commit d4bcc2b3bb
2 changed files with 5 additions and 2 deletions

View File

@ -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);
}
}
}