diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index d747e44cf93..2a337337f6a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -78,11 +78,12 @@ public XWPFParagraph(CTP prgrph, IBody part) { 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 XWPFParagraph(CTP prgrph, IBody part) { 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("] "); diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx new file mode 100644 index 00000000000..70f491c23a5 Binary files /dev/null and b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-6061520554164224.docx differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 84b3a84857a..ee43072f5c7 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ