Author: tilman
Date: Thu May 17 20:16:02 2018
New Revision: 1831808

URL: http://svn.apache.org/viewvc?rev=1831808&view=rev
Log:
PDFBOX-4222: ignore all page labels if there is a bad entry (similar to Adobe 
Reader)

Modified:
    
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java?rev=1831808&r1=1831807&r2=1831808&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
 (original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
 Thu May 17 20:16:02 2018
@@ -174,13 +174,20 @@ public class PDNumberTreeNode implements
     public Map<Integer,COSObjectable> getNumbers()  throws IOException
     {
         Map<Integer, COSObjectable> indices = null;
-        COSArray namesArray = (COSArray)node.getDictionaryObject( COSName.NUMS 
);
-        if( namesArray != null )
+        COSBase numBase = node.getDictionaryObject(COSName.NUMS);
+        if (numBase instanceof COSArray)
         {
+            COSArray namesArray = (COSArray) numBase;        
             indices = new HashMap<Integer,COSObjectable>();
             for( int i=0; i<namesArray.size(); i+=2 )
             {
-                COSInteger key = (COSInteger)namesArray.getObject(i);
+                COSBase base = namesArray.getObject(i);
+                if (!(base instanceof COSInteger))
+                {
+                    LOG.error("page labels ignored, index " + i + " should be 
a number, but is " + base);
+                    return null;
+                }
+                COSInteger key = (COSInteger) base;
                 COSBase cosValue = namesArray.getObject( i+1 );
                 COSObjectable pdValue = convertCOSToPD( cosValue );
                 indices.put( key.intValue(), pdValue );


Reply via email to