pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1767729 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Date Wed, 02 Nov 2016 16:49:31 GMT
Author: tilman
Date: Wed Nov  2 16:49:31 2016
New Revision: 1767729

URL: http://svn.apache.org/viewvc?rev=1767729&view=rev
Log:
PDFBOX-3546: catch exception and skip incorrect XRefStm

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=1767729&r1=1767728&r2=1767729&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 Wed Nov 
2 16:49:31 2016
@@ -249,6 +249,7 @@ public class COSParser extends BaseParse
                     fixedOffset = checkXRefStreamOffset(streamOffset, false);
                     if (fixedOffset > -1 && fixedOffset != streamOffset)
                     {
+                        LOG.warn("/XRefStm offset " + streamOffset + " is incorrect, corrected
to " + fixedOffset);
                         streamOffset = (int)fixedOffset;
                         trailer.setInt(COSName.XREF_STM, streamOffset);
                     }
@@ -256,7 +257,21 @@ public class COSParser extends BaseParse
                     {
                         source.seek(streamOffset);
                         skipSpaces();
-                        parseXrefObjStream(prev, false);
+                        try
+                        {
+                            parseXrefObjStream(prev, false);
+                        }
+                        catch (IOException ex)
+                        {
+                            if (isLenient)
+                            {
+                                LOG.error("Failed to parse /XRefStm at offset " + streamOffset,
ex);
+                            }
+                            else
+                            {
+                                throw ex;
+                            }
+                        }
                     }
                     else
                     {



Mime
View raw message