This is an automated email from the ASF dual-hosted git repository.

centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git

commit e9b33c0b08ccb1cdac6bfd6bcfe6cc0131a13c1a
Author: Dominik Stadler <[email protected]>
AuthorDate: Fri Jan 9 08:07:56 2026 +0100

    Avoid NPE with broken files when writing endnotes for Word documents
    
    Fixes https://issues.oss-fuzz.com/issues/392690733
---
 .../org/apache/poi/xwpf/usermodel/XWPFEndnotes.java |   5 +++++
 ...se-minimized-POIXWPFFuzzer-4961551840247808.docx | Bin 0 -> 35568 bytes
 test-data/spreadsheet/stress.xls                    | Bin 73728 -> 74752 bytes
 3 files changed, 5 insertions(+)

diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java 
b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java
index 549a746fc8..2c3d6d7626 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java
@@ -123,6 +123,11 @@ public class XWPFEndnotes extends 
XWPFAbstractFootnotesEndnotes {
 
     @Override
     protected void commit() throws IOException {
+        // cannot save anything if class is not initialized fully
+        if (ctEndnotes == null) {
+            return;
+        }
+
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
         xmlOptions.setSaveSyntheticDocumentElement(new 
QName(CTEndnotes.type.getName().getNamespaceURI(), "endnotes"));
         PackagePart part = getPackagePart();
diff --git 
a/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4961551840247808.docx
 
b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4961551840247808.docx
new file mode 100644
index 0000000000..cb604f0cc5
Binary files /dev/null and 
b/test-data/document/clusterfuzz-testcase-minimized-POIXWPFFuzzer-4961551840247808.docx
 differ
diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls
index cfc460f7d9..86981ef7c1 100644
Binary files a/test-data/spreadsheet/stress.xls and 
b/test-data/spreadsheet/stress.xls differ


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to