Skip to content

Commit dd647b5

Browse files
committed
Bug 66425: Avoid exceptions found via poi-fuzz
Prevent NullPointerException Fixes https://issues.oss-fuzz.com/issues/389724915 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923276 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9c24944 commit dd647b5

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java

+5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,14 @@ public Rectangle2D getAnchor(){
8484
}
8585
double x = Units.toPoints(POIXMLUnits.parseLength(off.xgetX()));
8686
double y = Units.toPoints(POIXMLUnits.parseLength(off.xgetY()));
87+
8788
CTPositiveSize2D ext = xfrm.getExt();
89+
if (ext == null) {
90+
throw new IllegalArgumentException("Could not retrieve Ext from the XML object");
91+
}
8892
double cx = Units.toPoints(ext.getCx());
8993
double cy = Units.toPoints(ext.getCy());
94+
9095
return new Rectangle2D.Double(x, y, cx, cy);
9196
}
9297

poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFShape.java

+4
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ protected PaintStyle selectPaint(CTStyleMatrixReference fillRef, final XSLFTheme
448448
// values 1-999 refer to the index of a fill style within the fillStyleLst element
449449
// values 1001 and above refer to the index of a background fill style within the bgFillStyleLst element.
450450
long idx = fillRef.getIdx();
451+
452+
if (theme == null || theme.getXmlObject() == null || theme.getXmlObject().getThemeElements() == null) {
453+
throw new IllegalArgumentException("Could not retrieve theme elements from shape");
454+
}
451455
CTStyleMatrix matrix = theme.getXmlObject().getThemeElements().getFmtScheme();
452456
final XmlObject styleLst;
453457
long childIdx;

test-data/spreadsheet/stress.xls

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)