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
This commit is contained in:
Dominik Stadler 2025-01-20 18:40:27 +00:00
parent 9c24944299
commit dd647b5d2d
4 changed files with 9 additions and 0 deletions

View File

@ -84,9 +84,14 @@ public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFSh
}
double x = Units.toPoints(POIXMLUnits.parseLength(off.xgetX()));
double y = Units.toPoints(POIXMLUnits.parseLength(off.xgetY()));
CTPositiveSize2D ext = xfrm.getExt();
if (ext == null) {
throw new IllegalArgumentException("Could not retrieve Ext from the XML object");
}
double cx = Units.toPoints(ext.getCx());
double cy = Units.toPoints(ext.getCy());
return new Rectangle2D.Double(x, y, cx, cy);
}

View File

@ -448,6 +448,10 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
// values 1-999 refer to the index of a fill style within the fillStyleLst element
// values 1001 and above refer to the index of a background fill style within the bgFillStyleLst element.
long idx = fillRef.getIdx();
if (theme == null || theme.getXmlObject() == null || theme.getXmlObject().getThemeElements() == null) {
throw new IllegalArgumentException("Could not retrieve theme elements from shape");
}
CTStyleMatrix matrix = theme.getXmlObject().getThemeElements().getFmtScheme();
final XmlObject styleLst;
long childIdx;

Binary file not shown.