[ 
https://issues.apache.org/jira/browse/PDFBOX-6286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128402#comment-18128402
 ] 

ASF subversion and git services commented on PDFBOX-6286:
---------------------------------------------------------

Commit 1939237 from Tilman Hausherr in branch 'pdfbox/branches/3.0'
[ https://svn.apache.org/r1939237 ]

PDFBOX-6286: avoid false recursion after an out-of-range lookup, by Aryan 
Ganjoo; closes #540

> PDPageTree.get reports false recursion after an out-of-range lookup
> -------------------------------------------------------------------
>
>                 Key: PDFBOX-6286
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6286
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Aryan Ganjoo
>            Priority: Minor
>
> h3. Observed
> On current PDFBox trunk {{e314c402afd4cac4d60d6d16dbe6525d83637ba8}}, an 
> out-of-range {{PDPageTree.get(1)}} on a one-page document throws as expected, 
> but a subsequent valid {{get(0)}} on the *same* tree throws 
> {{IllegalStateException: Possible recursion found when searching for page 
> 1}}. The document is generated in memory and contains no page-tree cycle.
> h3. Minimal reproduction
> {code:java}
> try (PDDocument document = new PDDocument()) {
>     PDPage page = new PDPage();
>     document.addPage(page);
>     PDPageTree pages = document.getPages();
>     try { pages.get(1); } catch (IndexOutOfBoundsException expected) { }
>     pages.get(0); // unexpectedly reports recursion
> }
> {code}
> h3. Cause and expected behavior
> The lookup keeps visited page dictionaries in an instance field. The failed 
> lookup adds the root and exits without clearing that field, so the next 
> lookup sees stale state. A fresh lookup should be able to retrieve page zero; 
> cycle detection should remain scoped to one traversal. This is separate from 
> PDFBOX-3349 (the out-of-range request itself) and PDFBOX-5278 (an 
> annotation/type mutation on a particular PDF).
> h3. Local validation and limits
> A regression failed on unmodified trunk and passed with a local candidate 
> that uses a per-lookup visited set. The affected {{TestPDPageTree}} class 
> passed 8 tests, zero failures/errors. The full suite, stable branches, 
> nested-cycle cases, and downstream use were not tested. No private PDF or 
> application data was used. This is an issue report, not a submitted patch. AI 
> assistance was used for discovery, test and patch preparation, and local 
> validation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to