pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leleu...@apache.org
Subject svn commit: r1435877 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
Date Sun, 20 Jan 2013 16:33:31 GMT
Author: leleueri
Date: Sun Jan 20 16:33:31 2013
New Revision: 1435877

URL: http://svn.apache.org/viewvc?rev=1435877&view=rev
Log:
PDFBOX-1497 : avoid ArrayOutOfBound on PDDeviceN.getAttributes

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java?rev=1435877&r1=1435876&r2=1435877&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
Sun Jan 20 16:33:31 2013
@@ -242,11 +242,16 @@ public class PDDeviceN extends PDColorSp
     {
         if ( deviceNAttributes == null )
         {
+        	if (array.size() > DEVICEN_ATTRIBUTES) { // the DeviceN contains an attributes
dictionary
             deviceNAttributes = new PDDeviceNAttributes((COSDictionary)array.getObject(DEVICEN_ATTRIBUTES));
+        	} else {
+        		// create the Attributes dictionary
+        		setAttributes(new PDDeviceNAttributes());
+        	}
         }
         return deviceNAttributes;
     }
-
+    
     /**
      * This will set the color space attributes.  If null is passed in then
      * all attribute will be removed.
@@ -272,6 +277,15 @@ public class PDDeviceN extends PDColorSp
     }
 
     /**
+     * Returns true if the DeviceN color space has an attributes dictionary
+     * @return
+     */
+    public boolean  hasAttributes()
+    {
+    	return array.size() > DEVICEN_ATTRIBUTES;
+    }
+    
+    /**
      * Returns the components of the color in the alternate colorspace for the given tint
value.
      * @param tintValues a list containing the tint values
      * @return COSArray with the color components

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java?rev=1435877&r1=1435876&r2=1435877&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
Sun Jan 20 16:33:31 2013
@@ -270,8 +270,8 @@ public class StandardColorSpaceHelper im
 			}
 
 			int numberOfColorants = 0;
-			PDDeviceNAttributes attr = deviceN.getAttributes();
-			if (attr != null) {
+			if ( deviceN.hasAttributes() ) {
+				PDDeviceNAttributes attr = deviceN.getAttributes();
 				Map colorants = attr.getColorants();
 				if (colorants != null) {
 					numberOfColorants = colorants.size();



Mime
View raw message