pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1755104 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
Date Wed, 03 Aug 2016 18:38:28 GMT
Author: tilman
Date: Wed Aug  3 18:38:27 2016
New Revision: 1755104

URL: http://svn.apache.org/viewvc?rev=1755104&view=rev
Log:
PDFBOX-2852: avoid unchecked exceptions

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.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=1755104&r1=1755103&r2=1755104&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 Wed Aug  3 18:38:27
2016
@@ -217,6 +217,12 @@ public class CFFParser
         for (int i = 0; i < count; i++)
         {
             int length = offsets[i + 1] - offsets[i];
+            if (length < 0)
+            {
+                throw new IOException("Negative index data length + " + length + " at " +

+                        i + ": offsets[" + (i + 1) + "]=" + offsets[i + 1] + 
+                        ", offsets[" + i + "]=" + offsets[i]);
+            }
             indexDataValues[i] = new String(input.readBytes(length), Charsets.ISO_8859_1);
         }
         return indexDataValues;
@@ -1113,19 +1119,19 @@ public class CFFParser
         public Boolean getBoolean(String name, boolean defaultValue)
         {
             Entry entry = getEntry(name);
-            return entry != null ? entry.getBoolean(0) : defaultValue;
+            return entry != null && entry.getArray().size() > 0 ? entry.getBoolean(0)
: defaultValue;
         }
 
         public List<Number> getArray(String name, List<Number> defaultValue)
         {
             Entry entry = getEntry(name);
-            return entry != null ? entry.getArray() : defaultValue;
+            return entry != null && entry.getArray().size() > 0 ? entry.getArray()
: defaultValue;
         }
 
         public Number getNumber(String name, Number defaultValue)
         {
             Entry entry = getEntry(name);
-            return entry != null ? entry.getNumber(0) : defaultValue;
+            return entry != null && entry.getArray().size() > 0 ? entry.getNumber(0)
: defaultValue;
         }
 
         /**



Mime
View raw message