pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1864745 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
Date Fri, 09 Aug 2019 04:00:58 GMT
Author: tilman
Date: Fri Aug  9 04:00:58 2019
New Revision: 1864745

URL: http://svn.apache.org/viewvc?rev=1864745&view=rev
Log:
PDFBOX-4626: avoid ArrayIndexOutOfBoundsException

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java?rev=1864745&r1=1864744&r2=1864745&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java Fri Aug  9
04:00:58 2019
@@ -142,6 +142,11 @@ public class CmapSubtable implements Cma
 
         glyphIdToCharacterCode = newGlyphIdToCharacterCode(numGlyphs);
         characterCodeToGlyphId = new HashMap<>(numGlyphs);
+        if (numGlyphs == 0)
+        {
+            LOG.warn("subtable has no glyphs");
+            return;
+        }
         // -- Read all sub header
         for (long i = 0; i < nbGroups; ++i)
         {
@@ -231,6 +236,11 @@ public class CmapSubtable implements Cma
         long nbGroups = data.readUnsignedInt();
         glyphIdToCharacterCode = newGlyphIdToCharacterCode(numGlyphs);
         characterCodeToGlyphId = new HashMap<>(numGlyphs);
+        if (numGlyphs == 0)
+        {
+            LOG.warn("subtable has no glyphs");
+            return;
+        }
         for (long i = 0; i < nbGroups; ++i)
         {
             long firstCode = data.readUnsignedInt();
@@ -282,6 +292,11 @@ public class CmapSubtable implements Cma
         long nbGroups = data.readUnsignedInt();
         glyphIdToCharacterCode = newGlyphIdToCharacterCode(numGlyphs);
         characterCodeToGlyphId = new HashMap<>(numGlyphs);
+        if (numGlyphs == 0)
+        {
+            LOG.warn("subtable has no glyphs");
+            return;
+        }
         for (long i = 0; i < nbGroups; ++i)
         {
             long firstCode = data.readUnsignedInt();
@@ -491,6 +506,11 @@ public class CmapSubtable implements Cma
         long startGlyphIndexOffset = data.getCurrentPosition();
         glyphIdToCharacterCode = newGlyphIdToCharacterCode(numGlyphs);
         characterCodeToGlyphId = new HashMap<>(numGlyphs);
+        if (numGlyphs == 0)
+        {
+            LOG.warn("subtable has no glyphs");
+            return;
+        }
         for (int i = 0; i <= maxSubHeaderIndex; ++i)
         {
             SubHeader sh = subHeaders[i];



Mime
View raw message