[ 
https://issues.apache.org/jira/browse/PDFBOX-6318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr updated PDFBOX-6318:
------------------------------------
    Affects Version/s: 2.0.37

> PDPageTree.add() and remove() loop forever when the page tree has a /Parent 
> cycle
> ---------------------------------------------------------------------------------
>
>                 Key: PDFBOX-6318
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6318
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.37, 3.0.8 PDFBox, 4.0.0
>            Reporter: Martin Mirchev
>            Priority: Major
>         Attachments: pages-parent-self.pdf
>
>
> {{PDPageTree.add()}}, {{remove()}} and {{increaseParents()}} (used by 
> {{insertBefore()}}/{{insertAfter()}}) update the {{/Count}} of every ancestor 
> by following {{/Parent}} until it is null. If the chain has a cycle they 
> never return.
> Attached {{pages-parent-self.pdf}} has a root {{Pages}} node whose 
> {{/Parent}} points to itself. It loads, {{getNumberOfPages()}} returns 2, but 
> {{doc.addPage(new PDPage())}} and {{doc.removePage(0)}} never return (thread 
> still in {{PDPageTree.add}} / {{remove}} after 30 s; trunk bd0c9c0, 3/3 
> runs). The same file without the cycle works.
> PDFBOX-3953 and PDFBOX-6040 handled cycles when reading the tree; these 
> update loops have no such check. Stopping at the root ({{this.root}}) or 
> keeping a set of visited nodes would avoid it.
> This issue was found by an LLM-assisted tool and verified manually.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to