You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/10/20 17:10:03 UTC

svn commit: r1844426 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Author: tilman
Date: Sat Oct 20 17:10:03 2018
New Revision: 1844426

URL: http://svn.apache.org/viewvc?rev=1844426&view=rev
Log:
PDFBOX-4357: check page tree root at the end of parsing

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1844426&r1=1844425&r2=1844426&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Sat Oct 20 17:10:03 2018
@@ -2278,8 +2278,9 @@ public class COSParser extends BaseParse
      * Check if all entries of the pages dictionary are present. Those which can't be dereferenced are removed.
      * 
      * @param root the root dictionary of the pdf
+     * @throws java.io.IOException if the page tree root is null
      */
-    protected void checkPages(COSDictionary root)
+    protected void checkPages(COSDictionary root) throws IOException
     {
         if (trailerWasRebuild && root != null)
         {
@@ -2289,6 +2290,15 @@ public class COSParser extends BaseParse
             {
                 checkPagesDictionary((COSDictionary) pages, new HashSet<COSObject>());
             }
+
+            if (pages instanceof COSObject)
+            {
+                pages = ((COSObject) pages).getObject();
+            }
+            if (pages == null || pages instanceof COSNull)
+            {
+                throw new IOException("Page tree root is null");
+            }
         }
     }