]> source.dussan.org Git - poi.git/commitdiff
Fix possible NullPointerException with invalid/unsupported image types
authorDominik Stadler <centic@apache.org>
Mon, 18 Jan 2016 19:56:30 +0000 (19:56 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 18 Jan 2016 19:56:30 +0000 (19:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1725332 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/sl/draw/DrawPaint.java
test-data/slideshow/br.com.tvcamboriu.www_pps_Pensar_5b1_5d.ppt [new file with mode: 0755]

index 94001fd88c3031f2dbdc53dcf1291e16d3969f37..8d5648f8527795c91216fb3fcaa443648c90f754 100644 (file)
@@ -27,6 +27,7 @@ import java.awt.RadialGradientPaint;
 import java.awt.geom.AffineTransform;\r
 import java.awt.geom.Point2D;\r
 import java.awt.geom.Rectangle2D;\r
+import java.awt.image.BufferedImage;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 \r
@@ -145,8 +146,13 @@ public class DrawPaint {
             renderer.setAlpha(alpha/100000.f);\r
         }\r
         \r
+        BufferedImage image = renderer.getImage();\r
+        if(image == null) {\r
+            LOG.log(POILogger.ERROR, "Can't load image data");\r
+            return null;\r
+        }\r
         Rectangle2D textAnchor = shape.getAnchor();\r
-        Paint paint = new java.awt.TexturePaint(renderer.getImage(), textAnchor);\r
+        Paint paint = new java.awt.TexturePaint(image, textAnchor);\r
 \r
         return paint;\r
     }\r
diff --git a/test-data/slideshow/br.com.tvcamboriu.www_pps_Pensar_5b1_5d.ppt b/test-data/slideshow/br.com.tvcamboriu.www_pps_Pensar_5b1_5d.ppt
new file mode 100755 (executable)
index 0000000..b3f01ed
Binary files /dev/null and b/test-data/slideshow/br.com.tvcamboriu.www_pps_Pensar_5b1_5d.ppt differ