Author: tilman
Date: Tue Sep 15 10:18:22 2026
New Revision: 1938232
Log:
PDFBOX-6266: avoid stack overflow with type 3 streams
Modified:
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Modified:
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
==============================================================================
---
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Tue Sep 15 09:15:19 2026 (r1938231)
+++
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Tue Sep 15 10:18:22 2026 (r1938232)
@@ -877,10 +877,23 @@ public abstract class PDFStreamEngine
protected void showType3Glyph(Matrix textRenderingMatrix, PDType3Font
font, int code,
Vector displacement) throws IOException
{
- PDType3CharProc charProc = font.getCharProc(code);
- if (charProc != null)
+ try
{
- processType3Stream(charProc, textRenderingMatrix);
+ increaseLevel();
+ if (getLevel() > 50)
+ {
+ LOG.error("recursion is too deep, skipping Type3 glyph");
+ return;
+ }
+ PDType3CharProc charProc = font.getCharProc(code);
+ if (charProc != null)
+ {
+ processType3Stream(charProc, textRenderingMatrix);
+ }
+ }
+ finally
+ {
+ decreaseLevel();
}
}