Author: tilman
Date: Thu May 17 19:40:21 2018
New Revision: 1831805

URL: http://svn.apache.org/viewvc?rev=1831805&view=rev
Log:
PDFBOX-4222: skip bad page label entry

Modified:
    
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java?rev=1831805&r1=1831804&r2=1831805&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
 (original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
 Thu May 17 19:40:21 2018
@@ -621,7 +621,13 @@ public class PDFMergerUtility
             {
                 for (int i = 0; i < srcNums.size(); i += 2)
                 {
-                    COSNumber labelIndex = (COSNumber) srcNums.getObject(i);
+                    COSBase base = srcNums.getObject(i);
+                    if (!(base instanceof COSNumber))
+                    {
+                        LOG.warn("page labels skipped at index " + i + ", 
should be a number, but is " + base);
+                        break;
+                    }
+                    COSNumber labelIndex = (COSNumber) base;
                     long labelIndexValue = labelIndex.intValue();
                     destNums.add(COSInteger.get(labelIndexValue + 
destPageCount));
                     
destNums.add(cloner.cloneForNewDocument(srcNums.getObject(i + 1)));


Reply via email to