pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1786603 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
Date Sun, 12 Mar 2017 18:26:19 GMT
Author: lehmi
Date: Sun Mar 12 18:26:19 2017
New Revision: 1786603

URL: http://svn.apache.org/viewvc?rev=1786603&view=rev
Log:
PDFBOX-3629: check for an object number if the read value is a COSNumber only

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=1786603&r1=1786602&r2=1786603&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Sun Mar
12 18:26:19 2017
@@ -150,26 +150,29 @@ public abstract class BaseParser
     private COSBase parseCOSDictionaryValue() throws IOException
     {
         long numOffset = seqSource.getPosition();
-        COSBase number = parseDirObject();
+        COSBase value = parseDirObject();
         skipSpaces();
-        if (!isDigit())
+        // proceed if the given object is a number and the following is a number as well
+        if (!(value instanceof COSNumber) || !isDigit())
         {
-            return number;
+            return value;
         }
+        // read the remaining information of the object number
         long genOffset = seqSource.getPosition();
         COSBase generationNumber = parseDirObject();
         skipSpaces();
         readExpectedChar('R');
-        if (!(number instanceof COSInteger))
+        if (!(value instanceof COSInteger))
         {
-            throw new IOException("expected number, actual=" + number + " at offset " + numOffset);
+            throw new IOException("expected number, actual=" + value + " at offset " + numOffset);
         }
         if (!(generationNumber instanceof COSInteger))
         {
-            throw new IOException("expected number, actual=" + number + " at offset " + genOffset);
+            throw new IOException("expected number, actual=" + value + " at offset " + genOffset);
         }
-        COSObjectKey key = new COSObjectKey(((COSInteger) number).longValue(),
+        COSObjectKey key = new COSObjectKey(((COSInteger) value).longValue(),
                 ((COSInteger) generationNumber).intValue());
+        // dereference the object
         return getObjectFromPool(key);
     }
 



Mime
View raw message