From ce22cc44c495e9a6289200596d0ab1cf2f4e84e2 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Fri, 5 Feb 2016 22:03:44 +0000 Subject: [PATCH] XSLF - fixed NPE when adding pictures with existing non-picture media files (e.g. movies) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1728737 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xslf/usermodel/XSLFPictureData.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java index 935d12331..3431d1c24 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java @@ -163,7 +163,13 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture byte data[] = getData(); checksum = IOUtils.calculateChecksum(data); - switch (getType()) { + PictureType pt = getType(); + if (pt == null) { + origSize = new Dimension(1,1); + return; + } + + switch (pt) { case EMF: origSize = new EMF.NativeHeader(data, 0).getSize(); break;