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,10 +127,13 @@ public class XWPFFootnotes extends XWPFAbstractFootnotesEndnotes {
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes")); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTFootnotes.type.getName().getNamespaceURI(), "footnotes"));
PackagePart part = getPackagePart(); PackagePart part = getPackagePart();
if (ctFootnotes != null) {
try (OutputStream out = part.getOutputStream()) { try (OutputStream out = part.getOutputStream()) {
ctFootnotes.save(out, xmlOptions); ctFootnotes.save(out, xmlOptions);
} }
} }
}
/** /**
* Add an {@link XWPFFootnote} to the document * Add an {@link XWPFFootnote} to the document