]> source.dussan.org Git - poi.git/commitdiff
add null check in XLSFPictureShape
authorPJ Fanning <fanningpj@apache.org>
Mon, 17 Dec 2018 09:17:29 +0000 (09:17 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 17 Dec 2018 09:17:29 +0000 (09:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1849069 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java

index 01f903e193565a0c4165198c44d077efde271f0d..ed11a6b19752593991f0e5af0671f1caa6f08128 100644 (file)
@@ -265,28 +265,28 @@ public class XSLFPictureShape extends XSLFSimpleShape
 
     public XSLFPictureData getSvgImage() {
         CTBlip blip = getBlip();
-        CTOfficeArtExtensionList extLst = blip.getExtLst();
-        if (extLst == null) {
-            return null;
-        }
+        if (blip != null) {
+            CTOfficeArtExtensionList extLst = blip.getExtLst();
+            if (extLst == null) {
+                return null;
+            }
 
-        int size = extLst.sizeOfExtArray();
-        for (int i=0; i<size; i++) {
-            XmlCursor cur = extLst.getExtArray(i).newCursor();
-            try {
-                if (cur.toChild(SVG_NS, "svgBlip")) {
-                    String svgRelId = cur.getAttributeText(new QName(CORE_PROPERTIES_ECMA376_NS, "embed"));
-                    return (svgRelId != null) ? (XSLFPictureData)getSheet().getRelationById(svgRelId) : null;
+            int size = extLst.sizeOfExtArray();
+            for (int i = 0; i < size; i++) {
+                XmlCursor cur = extLst.getExtArray(i).newCursor();
+                try {
+                    if (cur.toChild(SVG_NS, "svgBlip")) {
+                        String svgRelId = cur.getAttributeText(new QName(CORE_PROPERTIES_ECMA376_NS, "embed"));
+                        return (svgRelId != null) ? (XSLFPictureData) getSheet().getRelationById(svgRelId) : null;
+                    }
+                } finally {
+                    cur.dispose();
                 }
-            } finally {
-                cur.dispose();
             }
         }
-
         return null;
     }
 
-
     /**
      * Convienence method for adding SVG images, which generates the preview image
      * @param sheet the sheet to add