Skip to content

Commit

Permalink
Bug 66425: Avoid a NullPointerException found via oss-fuzz
Browse files Browse the repository at this point in the history
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
  • Loading branch information
centic9 committed Sep 6, 2023
1 parent b801711 commit 24bf8c3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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("] ");

Expand Down
Binary file not shown.
Binary file modified test-data/spreadsheet/stress.xls
Binary file not shown.

0 comments on commit 24bf8c3

Please sign in to comment.