pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1868409 - in /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf: GlyphSubstitutionTable.java gsub/GlyphSubstitutionDataExtractor.java
Date Sun, 13 Oct 2019 14:53:37 GMT
Author: tilman
Date: Sun Oct 13 14:53:36 2019
New Revision: 1868409

URL: http://svn.apache.org/viewvc?rev=1868409&view=rev
Log:
PDFBOX-4670: avoid ArrayIndexOutOfBoundsException discovered by Daniel Gredler

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java?rev=1868409&r1=1868408&r2=1868409&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
(original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
Sun Oct 13 14:53:36 2019
@@ -412,7 +412,10 @@ public class GlyphSubstitutionTable exte
 
         int[] componentGlyphIDs = new int[componentCount];
 
-        componentGlyphIDs[0] = coverageGlyphId;
+        if (componentCount > 0)
+        {
+            componentGlyphIDs[0] = coverageGlyphId;
+        }
 
         for (int i = 1; i <= componentCount - 1; i++)
         {

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java?rev=1868409&r1=1868408&r2=1868409&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java
(original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java
Sun Oct 13 14:53:36 2019
@@ -103,22 +103,27 @@ public class GlyphSubstitutionDataExtrac
             LangSysTable langSysTable, FeatureListTable featureListTable,
             LookupListTable lookupListTable)
     {
+        FeatureRecord[] featureRecords = featureListTable.getFeatureRecords();
         for (int featureIndex : langSysTable.getFeatureIndices())
         {
-            FeatureRecord featureRecord = featureListTable.getFeatureRecords()[featureIndex];
-            populateGsubData(gsubData, featureRecord, lookupListTable);
+            if (featureIndex < featureRecords.length)
+            {
+                populateGsubData(gsubData, featureRecords[featureIndex], lookupListTable);
+            }
         }
     }
 
     private void populateGsubData(Map<String, Map<List<Integer>, Integer>>
gsubData,
             FeatureRecord featureRecord, LookupListTable lookupListTable)
     {
-
+        LookupTable[] lookups = lookupListTable.getLookups();
         Map<List<Integer>, Integer> glyphSubstitutionMap = new LinkedHashMap<>();
         for (int lookupIndex : featureRecord.getFeatureTable().getLookupListIndices())
         {
-            LookupTable lookupTable = lookupListTable.getLookups()[lookupIndex];
-            extractData(glyphSubstitutionMap, lookupTable);
+            if (lookupIndex < lookups.length)
+            {
+                extractData(glyphSubstitutionMap, lookups[lookupIndex]);
+            }
         }
 
         LOG.debug("*********** extracting GSUB data for the feature: "



Mime
View raw message