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

Maruan Sahyoun updated PDFBOX-6391:
-----------------------------------
    Fix Version/s: 2.0.38
                   3.0.9 PDFBox
                   4.0.0

> Clone shared objects only once when merging and splitting
> ---------------------------------------------------------
>
>                 Key: PDFBOX-6391
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6391
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.0.37, 3.0.8 PDFBox, 4.0.0
>            Reporter: Maruan Sahyoun
>            Assignee: Maruan Sahyoun
>            Priority: Minor
>             Fix For: 2.0.38, 3.0.9 PDFBox, 4.0.0
>
>
> When merging documents, `PDFCloneUtility.cloneMerge` merges dictionaries and 
> arrays like `/Names`, `/Dests` and `/OCProperties` recursively without 
> remembering what was already merged. Objects which are referenced more than 
> once are merged again for each reference, so a small file with a few levels 
> of shared dictionaries makes the merge run practically forever, and a cycle 
> never ends. The same pair of objects merged twice also adds array entries 
> twice.
> When splitting documents, `Splitter` clones the structure tree. Structure 
> elements are cloned only once, but arrays are cloned again for each 
> reference, and so are structure elements which don't belong to the split 
> part. A small tagged file with a few levels of shared arrays makes the split 
> run for a very long time and run out of memory.
> Proposed change
>  - Merge each pair of source and target objects only once in `cloneMerge`
>  - Clone shared arrays of the structure tree only once in `Splitter`, and 
> remember structure elements without a clone
>  - Add tests for merging shared dictionaries and for splitting a structure 
> tree with shared arrays and structure elements
> Found by a Claude security scan.
> Claude on behalf of Maruan Sahyoun (msahyoun)



--
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