pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1707336 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetGraphicsStateParameters.java
Date Wed, 07 Oct 2015 16:45:48 GMT
Author: tilman
Date: Wed Oct  7 16:45:48 2015
New Revision: 1707336

URL: http://svn.apache.org/viewvc?rev=1707336&view=rev
Log:
PDFBOX-2852: avoid exceptions (NPE, AOOB, CCE)

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetGraphicsStateParameters.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetGraphicsStateParameters.java?rev=1707336&r1=1707335&r2=1707336&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetGraphicsStateParameters.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetGraphicsStateParameters.java
Wed Oct  7 16:45:48 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.pdfbox.contentstream.operator.state;
 
+import java.io.IOException;
 import java.util.List;
 
 import org.apache.pdfbox.cos.COSBase;
@@ -23,8 +24,7 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
 import org.apache.pdfbox.contentstream.operator.Operator;
 import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
-
-import java.io.IOException;
+import org.apache.pdfbox.contentstream.operator.MissingOperandException;
 
 /**
  * gs: Set parameters from graphics state parameter dictionary.
@@ -36,9 +36,23 @@ public class SetGraphicsStateParameters
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
+        if (arguments.size() < 1)
+        {
+            throw new MissingOperandException(operator, arguments);
+        }
+        COSBase base0 = arguments.get(0);
+        if (!(base0 instanceof COSName))
+        {
+            return;
+        }
+        
         // set parameters from graphics state parameter dictionary
-        COSName graphicsName = (COSName)arguments.get( 0 );
+        COSName graphicsName = (COSName) base0;
         PDExtendedGraphicsState gs = context.getResources().getExtGState(graphicsName);
+        if (gs == null)
+        {
+            throw new IOException("name for 'gs' operator not found in resources: /" + graphicsName.getName());
+        }
         gs.copyIntoGraphicsState( context.getGraphicsState() );
     }
 



Mime
View raw message