diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 56e0c6d8f2..a8a1af4ca9 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -1430,8 +1430,9 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { } if (o instanceof CTFtnEdnRef) { CTFtnEdnRef ftn = (CTFtnEdnRef) o; + final int i = ftn.getId() == null ? -1 : ftn.getId().intValue(); String footnoteRef = ftn.getDomNode().getLocalName().equals("footnoteReference") ? - "[footnoteRef:" + ftn.getId().intValue() + "]" : "[endnoteRef:" + ftn.getId().intValue() + "]"; + "[footnoteRef:" + i + "]" : "[endnoteRef:" + i + "]"; text.append(footnoteRef); } } diff --git a/test-data/document/crash-517626e815e0afa9decd0ebb6d1dee63fb9907dd.docx b/test-data/document/crash-517626e815e0afa9decd0ebb6d1dee63fb9907dd.docx new file mode 100644 index 0000000000..e98f30e13f Binary files /dev/null and b/test-data/document/crash-517626e815e0afa9decd0ebb6d1dee63fb9907dd.docx differ