You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/07/29 21:18:44 UTC

svn commit: r1614466 - /pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamEngine.java

Author: tilman
Date: Tue Jul 29 19:18:44 2014
New Revision: 1614466

URL: http://svn.apache.org/r1614466
Log:
PDFBOX-2020: avoid NPE if there is no colorspaces resource

Modified:
    pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamEngine.java

Modified: pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamEngine.java?rev=1614466&r1=1614465&r2=1614466&view=diff
==============================================================================
--- pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamEngine.java (original)
+++ pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/content/ContentStreamEngine.java Tue Jul 29 19:18:44 2014
@@ -581,13 +581,17 @@ public abstract class ContentStreamEngin
             /*
              * The color space is unknown. Try to access the resources dictionary, the color space can be a reference.
              */
-            PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(colorSpaceName);
-            if (pdCS != null)
+            Map<String, PDColorSpace> colorSpaces = this.getResources().getColorSpaces();
+            if (colorSpaces != null)
             {
-                cs = ColorSpaces.valueOf(pdCS.getName());
-                PreflightConfiguration cfg = context.getConfig();
-                ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
-                csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_RESTRICTION);
+                PDColorSpace pdCS = colorSpaces.get(colorSpaceName);
+                if (pdCS != null)
+                {
+                    cs = ColorSpaces.valueOf(pdCS.getName());
+                    PreflightConfiguration cfg = context.getConfig();
+                    ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
+                    csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.NO_RESTRICTION);
+                }
             }
         }