Skip to content

Commit b489432

Browse files
committed
PDFBOX-6105: maxComponentDepth should be at least 1
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929989 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8a19ab2 commit b489432

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private GlyphData getGlyphData(int gid, int level) throws IOException
174174
{
175175
if (level > maxp.getMaxComponentDepth())
176176
{
177-
throw new IOException("composite glyph maximum level reached");
177+
throw new IOException("composite glyph maximum level (" + maxp.getMaxComponentDepth() + ") reached");
178178
}
179179
GlyphData glyph = new GlyphData();
180180
int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid);

fontbox/src/main/java/org/apache/fontbox/ttf/MaximumProfileTable.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818

1919
import java.io.IOException;
2020

21+
import org.apache.logging.log4j.LogManager;
22+
import org.apache.logging.log4j.Logger;
23+
2124
/**
2225
* This 'maxp'-table is a required table in a TrueType font.
2326
*
2427
* @author Ben Litchfield
2528
*/
2629
public class MaximumProfileTable extends TTFTable
2730
{
31+
private static final Logger LOG = LogManager.getLogger(MaximumProfileTable.class);
32+
2833
/**
2934
* A tag that identifies this table type.
3035
*/
@@ -48,7 +53,6 @@ public class MaximumProfileTable extends TTFTable
4853

4954
MaximumProfileTable()
5055
{
51-
super();
5256
}
5357

5458
/**
@@ -289,6 +293,11 @@ void read(TrueTypeFont ttf, TTFDataStream data) throws IOException
289293
maxSizeOfInstructions = data.readUnsignedShort();
290294
maxComponentElements = data.readUnsignedShort();
291295
maxComponentDepth = data.readUnsignedShort();
296+
if (maxComponentDepth == 0)
297+
{
298+
LOG.warn("maxComponentDepth is 0, set to 1");
299+
maxComponentDepth = 1;
300+
}
292301
}
293302
initialized = true;
294303
}

0 commit comments

Comments
 (0)