pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1783511 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetTextRenderingMode.java
Date Sat, 18 Feb 2017 11:10:19 GMT
Author: tilman
Date: Sat Feb 18 11:10:19 2017
New Revision: 1783511

URL: http://svn.apache.org/viewvc?rev=1783511&view=rev
Log:
PDFBOX-3692: avoid ArrayIndexOutOfBoundsException

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetTextRenderingMode.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetTextRenderingMode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetTextRenderingMode.java?rev=1783511&r1=1783510&r2=1783511&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetTextRenderingMode.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/SetTextRenderingMode.java
Sat Feb 18 11:10:19 2017
@@ -16,16 +16,15 @@
  */
 package org.apache.pdfbox.contentstream.operator.text;
 
+import java.io.IOException;
 import java.util.List;
 
+import org.apache.pdfbox.contentstream.operator.MissingOperandException;
+import org.apache.pdfbox.contentstream.operator.Operator;
+import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode;
-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;
 
 /**
  * Tr: Set text rendering mode.
@@ -47,7 +46,12 @@ public class SetTextRenderingMode extend
             return;
         }
         COSNumber mode = (COSNumber) base0;
-        RenderingMode renderingMode = RenderingMode.fromInt(mode.intValue());
+        int val = mode.intValue();
+        if (val < 0 || val >= RenderingMode.values().length)
+        {
+            return;
+        }
+        RenderingMode renderingMode = RenderingMode.fromInt(val);
         context.getGraphicsState().getTextState().setRenderingMode(renderingMode);
     }
 



Mime
View raw message