pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1831809 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
Date Thu, 17 May 2018 20:16:06 GMT
Author: tilman
Date: Thu May 17 20:16:06 2018
New Revision: 1831809

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

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java?rev=1831809&r1=1831808&r2=1831809&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
Thu May 17 20:16:06 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<>();
             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 );



Mime
View raw message