mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-28 03:58:45 -06:00
document_scripts_named walked the catalog's /Names /JavaScript tree by resolving and deep-cloning every kid onto its stack before looking at it. The 10,000 cap counted nodes taken off the stack, not what went on it, so a node whose /Kids lists itself k times pushed k full copies of itself (each holding its k-entry /Kids array) per visit. A 6.5 KB file with k = 1000 made `pdfcraft-cli run` (doc_open, js_document_scripts) exhaust an 8 GB address space in 8 seconds and abort; the same walk runs when a field edit sets up the script runner. A tree that lists a leaf twice returned its script twice. Keep kids unresolved on the stack and skip references already read, as the /Dests walker in organize does. The cap stays. Co-authored-by: Brandon Thomas <echelon@gmail.com>