From f2a8846bd4969450f39e335e638c13f59cba1ff3 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 935d12331e..3431d1c241 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; -- 2.39.5