You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/10/13 14:53:33 UTC
svn commit: r1868408 - in
/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf:
GlyphSubstitutionTable.java gsub/GlyphSubstitutionDataExtractor.java
Author: tilman
Date: Sun Oct 13 14:53:32 2019
New Revision: 1868408
URL: http://svn.apache.org/viewvc?rev=1868408&view=rev
Log:
PDFBOX-4670: avoid ArrayIndexOutOfBoundsException discovered by Daniel Gredler
Modified:
pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java
Modified: pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java?rev=1868408&r1=1868407&r2=1868408&view=diff
==============================================================================
--- pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java (original)
+++ pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphSubstitutionTable.java Sun Oct 13 14:53:32 2019
@@ -404,7 +404,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/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java?rev=1868408&r1=1868407&r2=1868408&view=diff
==============================================================================
--- pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java (original)
+++ pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/ttf/gsub/GlyphSubstitutionDataExtractor.java Sun Oct 13 14:53:32 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: "