You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (Jira)" <ji...@apache.org> on 2025/11/15 10:40:00 UTC
[jira] [Resolved] (PDFBOX-6097) Avoid StackOverflow when collecting indirect object keys
[ https://issues.apache.org/jira/browse/PDFBOX-6097?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Lehmkühler resolved PDFBOX-6097.
----------------------------------------
Resolution: Fixed
> Avoid StackOverflow when collecting indirect object keys
> --------------------------------------------------------
>
> Key: PDFBOX-6097
> URL: https://issues.apache.org/jira/browse/PDFBOX-6097
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 3.0.6 PDFBox, 4.0.0
> Reporter: Andreas Lehmkühler
> Assignee: Andreas Lehmkühler
> Priority: Major
> Fix For: 3.0.7 PDFBox, 4.0.0
>
>
> Kiran Kandel reports an issue on [Stackoverflow | https://stackoverflow.com/questions/79815248/stack-overflow-when-collecting-indirect-object-keys-from-recursive-pdf-structure]
> The following code sample results in a StackoverflowException
> {code}
> PDDocument document = new PDDocument();
> PDPage page = new PDPage(PDRectangle.A4);
> // Create AcroForm
> PDAcroForm acroForm = new PDAcroForm(document);
> document.getDocumentCatalog().setAcroForm(acroForm);
> // Create a single text field
> PDTextField textField = new PDTextField(acroForm);
> textField.setPartialName("testField");
> PDAnnotationWidget widget = textField.getWidgets().get(0);
> widget.setRectangle(new PDRectangle(100, 700, 200, 20));
> widget.setPage(page);
> page.getAnnotations().add(widget);
> acroForm.getFields().add(textField);
> // Adding page AFTER creating form fields causes StackOverflowError
> document.addPage(page);
> document.save("output.pdf");
> document.close();
> {code}
> [~tilman] already found the reason for the issue. The method in question detects and skips parent references to avoid recursion. This works fine as long as the key PARENT is used. In combination with annotations the abbreviated key P is used but isn't detected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org