Bug 66425: Avoid a NullPointerException found via oss-fuzz

We try to avoid throwing NullPointerException, but it was possible
to trigger one here with a specially crafted input-file

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-09-06 14:33:59 +00:00
parent b801711afe
commit 24bf8c33f2
3 changed files with 5 additions and 4 deletions

View File

@ -78,11 +78,12 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
XmlObject o = c.getObject();
if (o instanceof CTFtnEdnRef) {
CTFtnEdnRef ftn = (CTFtnEdnRef) o;
footnoteText.append(" [").append(ftn.getId()).append(": ");
final BigInteger id = ftn.getId();
footnoteText.append(" [").append(id).append(": ");
XWPFAbstractFootnoteEndnote footnote =
ftn.getDomNode().getLocalName().equals("footnoteReference") ?
document.getFootnoteByID(ftn.getId().intValue()) :
document.getEndnoteByID(ftn.getId().intValue());
document.getFootnoteByID(id == null ? 0 : id.intValue()) :
document.getEndnoteByID(id == null ? 0 : id.intValue());
if (null != footnote) {
boolean first = true;
for (XWPFParagraph p : footnote.getParagraphs()) {
@ -93,7 +94,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
footnoteText.append(p.getText());
}
} else {
footnoteText.append("!!! End note with ID \"").append(ftn.getId()).append("\" not found in document.");
footnoteText.append("!!! End note with ID \"").append(id).append("\" not found in document.");
}
footnoteText.append("] ");

Binary file not shown.