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:02:15 UTC

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

Author: tilman
Date: Tue Jul 29 19:02:15 2014
New Revision: 1614459

URL: http://svn.apache.org/r1614459
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=1614459&r1=1614458&r2=1614459&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:02:15 2014
@@ -323,17 +323,19 @@ public abstract class ContentStreamEngin
                 }
                 catch (IllegalArgumentException e)
                 {
-                    /*
-                     * The color space is unknown. Try to access the resources dictionary, the color space can be a
-                     * reference.
-                     */
-                    PDColorSpace pdCS = (PDColorSpace) this.getColorSpaces().get(colorSpace);
-                    if (pdCS != null)
+                    // The color space is unknown. Try to access the resources dictionary,
+                    // the color space can be a reference.
+                    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.ONLY_DEVICE);
+                        PDColorSpace pdCS = colorSpaces.get(colorSpace);
+                        if (pdCS != null)
+                        {
+                            cs = ColorSpaces.valueOf(pdCS.getName());
+                            PreflightConfiguration cfg = context.getConfig();
+                            ColorSpaceHelperFactory csFact = cfg.getColorSpaceHelperFact();
+                            csHelper = csFact.getColorSpaceHelper(context, pdCS, ColorSpaceRestriction.ONLY_DEVICE);
+                        }
                     }
                 }