pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1745040 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetFlatness.java
Date Sun, 22 May 2016 13:31:15 GMT
Author: tilman
Date: Sun May 22 13:31:15 2016
New Revision: 1745040

URL: http://svn.apache.org/viewvc?rev=1745040&view=rev
Log:
PDFBOX-2852: avoid ClassCastException / ArrayOutOfBoundsExceptions

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetFlatness.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetFlatness.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetFlatness.java?rev=1745040&r1=1745039&r2=1745040&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetFlatness.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetFlatness.java
Sun May 22 13:31:15 2016
@@ -19,6 +19,7 @@ package org.apache.pdfbox.contentstream.
 
 import java.io.IOException;
 import java.util.List;
+import org.apache.pdfbox.contentstream.operator.MissingOperandException;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.contentstream.operator.Operator;
@@ -34,7 +35,15 @@ public class SetFlatness extends Operato
     @Override
     public void process(Operator operator, List<COSBase> operands) throws IOException
     {
-        COSNumber value = (COSNumber)operands.get(0);
+        if (operands.size() < 1)
+        {
+            throw new MissingOperandException(operator, operands);
+        }
+        if (!checkArrayTypesClass(operands, COSNumber.class))
+        {
+            return;
+        }
+        COSNumber value = (COSNumber) operands.get(0);
         context.getGraphicsState().setFlatness(value.floatValue());
     }
 



Mime
View raw message