pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1825112 - in /pdfbox/trunk: fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Date Fri, 23 Feb 2018 07:04:27 GMT
Author: msahyoun
Date: Fri Feb 23 07:04:27 2018
New Revision: 1825112

URL: http://svn.apache.org/viewvc?rev=1825112&view=rev
Log:
PDFBOX-4122: add test where index data could be null - malformed CFF only; setting expected
number of char strings to 0

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java?rev=1825112&r1=1825111&r2=1825112&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java Fri Feb 23 07:04:27
2018
@@ -519,7 +519,19 @@ public class CFFParser
         // format-specific dictionaries
         if (isCIDFont)
         {
-            parseCIDFontDicts(input, topDict, (CFFCIDFont) font, charStringsIndex.length);
+
+            // CharStrings index could be null if the index data couldn't be read
+            int numEntries = 0;
+            if (charStringsIndex == null)
+            {
+                LOG.debug("Couldn't read CharStrings index - parsing CIDFontDicts with number
of char strings set to 0");
+            }
+            else
+            {
+                numEntries = charStringsIndex.length;
+            }
+
+            parseCIDFontDicts(input, topDict, (CFFCIDFont) font, numEntries);
 
             List<Number> privMatrix = null;
             List<Map<String, Object>> fontDicts = ((CFFCIDFont) font).getFontDicts();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1825112&r1=1825111&r2=1825112&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Fri Feb 23
07:04:27 2018
@@ -506,22 +506,22 @@ public class COSWriter implements ICOSVi
      */
     public void doWriteObject( COSBase obj ) throws IOException
     {
-        writtenObjects.add( obj );
-        // find the physical reference
-        currentObjectKey = getObjectKey( obj );
-        // add a x ref entry
-        addXRefEntry( new COSWriterXRefEntry(getStandardOutput().getPos(), obj, currentObjectKey));
-        // write the object
-        getStandardOutput().write(String.valueOf(currentObjectKey.getNumber()).getBytes(Charsets.ISO_8859_1));
-        getStandardOutput().write(SPACE);
-        getStandardOutput().write(String.valueOf(currentObjectKey.getGeneration()).getBytes(Charsets.ISO_8859_1));
-        getStandardOutput().write(SPACE);
-        getStandardOutput().write(OBJ);
-        getStandardOutput().writeEOL();
-        obj.accept( this );
-        getStandardOutput().writeEOL();
-        getStandardOutput().write(ENDOBJ);
-        getStandardOutput().writeEOL();
+            writtenObjects.add( obj );
+            // find the physical reference
+            currentObjectKey = getObjectKey( obj );
+            // add a x ref entry
+            addXRefEntry( new COSWriterXRefEntry(getStandardOutput().getPos(), obj, currentObjectKey));
+            // write the object
+            getStandardOutput().write(String.valueOf(currentObjectKey.getNumber()).getBytes(Charsets.ISO_8859_1));
+            getStandardOutput().write(SPACE);
+            getStandardOutput().write(String.valueOf(currentObjectKey.getGeneration()).getBytes(Charsets.ISO_8859_1));
+            getStandardOutput().write(SPACE);
+            getStandardOutput().write(OBJ);
+            getStandardOutput().writeEOL();
+            obj.accept( this );
+            getStandardOutput().writeEOL();
+            getStandardOutput().write(ENDOBJ);
+            getStandardOutput().writeEOL();
     }
 
     /**
@@ -1179,12 +1179,12 @@ public class COSWriter implements ICOSVi
      */
     public void writeReference(COSBase obj) throws IOException
     {
-        COSObjectKey key = getObjectKey(obj);
-        getStandardOutput().write(String.valueOf(key.getNumber()).getBytes(Charsets.ISO_8859_1));
-        getStandardOutput().write(SPACE);
-        getStandardOutput().write(String.valueOf(key.getGeneration()).getBytes(Charsets.ISO_8859_1));
-        getStandardOutput().write(SPACE);
-        getStandardOutput().write(REFERENCE);
+            COSObjectKey key = getObjectKey(obj);
+            getStandardOutput().write(String.valueOf(key.getNumber()).getBytes(Charsets.ISO_8859_1));
+            getStandardOutput().write(SPACE);
+            getStandardOutput().write(String.valueOf(key.getGeneration()).getBytes(Charsets.ISO_8859_1));
+            getStandardOutput().write(SPACE);
+            getStandardOutput().write(REFERENCE);
     }
 
     @Override



Mime
View raw message