Bug 66425: Avoid a ClassCastException found via oss-fuzz

We try to avoid throwing ClassCastException, 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@1912140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-09-06 14:58:31 +00:00
parent 5d073e3586
commit aad473eaca
2 changed files with 2 additions and 2 deletions

View File

@ -312,11 +312,11 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
for (RelationPart rp : getRelationParts()) {
POIXMLDocumentPart p = rp.getDocumentPart();
String relation = rp.getRelationship().getRelationshipType();
if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) {
if (relation.equals(XWPFRelation.FOOTNOTE.getRelation()) && p instanceof XWPFFootnotes) {
this.footnotes = (XWPFFootnotes) p;
this.footnotes.onDocumentRead();
this.footnotes.setIdManager(footnoteIdManager);
} else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) {
} else if (relation.equals(XWPFRelation.ENDNOTE.getRelation()) && p instanceof XWPFEndnotes) {
this.endnotes = (XWPFEndnotes) p;
this.endnotes.onDocumentRead();
this.endnotes.setIdManager(footnoteIdManager);