pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1705095 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator: DrawObject.java graphics/DrawObject.java
Date Thu, 24 Sep 2015 16:20:43 GMT
Author: tilman
Date: Thu Sep 24 16:20:42 2015
New Revision: 1705095

URL: http://svn.apache.org/viewvc?rev=1705095&view=rev
Log:
PDFBOX-2982: avoid ArrayOutOfBoundsException / ClassCastException

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java?rev=1705095&r1=1705094&r2=1705095&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/DrawObject.java
Thu Sep 24 16:20:42 2015
@@ -36,7 +36,16 @@ public class DrawObject extends Operator
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        COSName name = (COSName) arguments.get(0);
+        if (arguments.size() < 1)
+        {
+            throw new MissingOperandException(operator, arguments);
+        }
+        COSBase base0 = arguments.get(0);
+        if (!(base0 instanceof COSName))
+        {
+            return;
+        }
+        COSName name = (COSName) base0;
         PDXObject xobject =  context.getResources().getXObject(name);
         if (context instanceof PDFMarkedContentExtractor)
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java?rev=1705095&r1=1705094&r2=1705095&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/graphics/DrawObject.java
Thu Sep 24 16:20:42 2015
@@ -18,6 +18,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.COSName;
@@ -38,7 +39,16 @@ public final class DrawObject extends Gr
     @Override
     public void process(Operator operator, List<COSBase> operands) throws IOException
     {
-        COSName objectName = (COSName)operands.get(0);
+        if (operands.size() < 1)
+        {
+            throw new MissingOperandException(operator, operands);
+        }
+        COSBase base0 = operands.get(0);
+        if (!(base0 instanceof COSName))
+        {
+            return;
+        }
+        COSName objectName = (COSName) base0;
         PDXObject xobject = context.getResources().getXObject(objectName);
 
         if (xobject == null)



Mime
View raw message