[
https://issues.apache.org/jira/browse/PDFBOX-6097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18038540#comment-18038540
]
Andreas Lehmkühler commented on PDFBOX-6097:
--------------------------------------------
I've removed PARENT_KEYS to avoid misunderstandings and simplified the code a
little
> 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: [email protected]
For additional commands, e-mail: [email protected]