pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1813605 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
Date Sat, 28 Oct 2017 10:45:00 GMT
Author: tilman
Date: Sat Oct 28 10:44:59 2017
New Revision: 1813605

URL: http://svn.apache.org/viewvc?rev=1813605&view=rev
Log:
PDFBOX-3950: avoid NPE or CCE

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java?rev=1813605&r1=1813604&r2=1813605&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java Sat
Oct 28 10:44:59 2017
@@ -62,15 +62,22 @@ public class PDType0Font extends PDFont
     public PDType0Font(COSDictionary fontDictionary) throws IOException
     {
         super(fontDictionary);
-        COSArray descendantFonts = (COSArray)dict.getDictionaryObject(COSName.DESCENDANT_FONTS);
-        COSDictionary descendantFontDictionary = (COSDictionary) descendantFonts.getObject(0);
-
-        if (descendantFontDictionary == null)
+        COSBase base = dict.getDictionaryObject(COSName.DESCENDANT_FONTS);
+        if (!(base instanceof COSArray))
+        {
+            throw new IOException("Missing descendant font array");
+        }
+        COSArray descendantFonts = (COSArray) base;
+        if (descendantFonts.size() == 0)
+        {
+            throw new IOException("Descendant font array is empty");
+        }
+        COSBase descendantFontDictBase = descendantFonts.getObject(0);
+        if (!(descendantFontDictBase instanceof COSDictionary))
         {
             throw new IOException("Missing descendant font dictionary");
         }
-
-        descendantFont = PDFontFactory.createDescendantFont(descendantFontDictionary, this);
+        descendantFont = PDFontFactory.createDescendantFont((COSDictionary) descendantFontDictBase,
this);
         readEncoding();
         fetchCMapUCS2();
     }



Mime
View raw message