From c79fb75cbccccfa65aa7343a793f6284dd7510f0 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Thu, 21 Sep 2023 15:06:28 +0000 Subject: Bug 66425: Avoid exceptions found via poi-fuzz We try to avoid throwing NullPointerException, ClassCastExceptions and StackOverflowException, but it was possible to trigger them Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62548 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62564 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912464 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/poi/xslf/usermodel/XSLFDiagram.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'poi-ooxml/src') diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFDiagram.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFDiagram.java index 9837b5c128..2d14b4f13c 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFDiagram.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFDiagram.java @@ -214,8 +214,12 @@ public class XSLFDiagram extends XSLFGraphicFrame { CTGroupShapeProperties groupShapePropsCt = groupShapeCt.addNewGrpSpPr(); CTGroupShapeNonVisual groupShapeNonVisualCt = groupShapeCt.addNewNvGrpSpPr(); - groupShapeNonVisualCt.setCNvPr(msGroupShapeCt.getNvGrpSpPr().getCNvPr()); - groupShapeNonVisualCt.setCNvGrpSpPr(msGroupShapeCt.getNvGrpSpPr().getCNvGrpSpPr()); + final com.microsoft.schemas.office.drawing.x2008.diagram.CTGroupShapeNonVisual nvGrpSpPr = + msGroupShapeCt.getNvGrpSpPr(); + if (nvGrpSpPr != null) { + groupShapeNonVisualCt.setCNvPr(nvGrpSpPr.getCNvPr()); + groupShapeNonVisualCt.setCNvGrpSpPr(nvGrpSpPr.getCNvGrpSpPr()); + } groupShapeNonVisualCt.setNvPr(CTApplicationNonVisualDrawingProps.Factory.newInstance()); for (CTShape msShapeCt : msGroupShapeCt.getSpList()) { -- cgit v1.2.3