Skip to content

Commit

Permalink
PDFBOX-5901: avoid logging going mad
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1921899 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Nov 15, 2024
1 parent afd4cb2 commit b4fa8c5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -516,6 +518,8 @@ void processSubtype2(TTFDataStream data, int numGlyphs) throws IOException
LOG.warn("subtable has no glyphs");
return;
}
Set<Integer> logged = new HashSet<>();
boolean maxLoggingReached = false;
for (int i = 0; i <= maxSubHeaderIndex; ++i)
{
SubHeader sh = subHeaders[i];
Expand Down Expand Up @@ -547,8 +551,17 @@ void processSubtype2(TTFDataStream data, int numGlyphs) throws IOException

if (p >= numGlyphs)
{
LOG.warn("glyphId {} for charcode {} ignored, numGlyphs is {}", p, charCode,
numGlyphs);
if (!maxLoggingReached && !logged.contains(p))
{
LOG.warn("glyphId {} for charcode {} ignored, numGlyphs is {}", p, charCode,
numGlyphs);
logged.add(p);
if (logged.size() > 10)
{
LOG.warn("too many bad glyphIds, more won't be reported for this table");
maxLoggingReached = true;
}
}
continue;
}

Expand Down

0 comments on commit b4fa8c5

Please sign in to comment.