diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java index 84a02e10f7..225a8f496e 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java @@ -71,11 +71,11 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo */ public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part) { super(parent, part); - this.document = (XWPFDocument) getParent(); - - if (this.document == null) { - throw new NullPointerException(); + final POIXMLDocumentPart p = getParent(); + if (!(p instanceof XWPFDocument)) { + throw new IllegalArgumentException("Had unexpected type of parent: " + (p == null ? "" : p.getClass())); } + this.document = (XWPFDocument) p; } @Override diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java index 074a941669..83ed6c11f1 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java @@ -271,4 +271,12 @@ public final class XWPFRelation extends POIXMLRelation { return _table.get(rel); } + @Override + public String toString() { + return "XWPFRelation{" + + //getRelation() + "/" + + getContentType() + "/" + + getDefaultFileName() + + "}"; + } } diff --git a/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx new file mode 100644 index 0000000000..fc5d388422 Binary files /dev/null and b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4959857092198400.docx differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index a47f99b2cb..eeecaeb553 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ